mirror of
https://github.com/Klagarge/PokeHES.git
synced 2024-11-23 09:53:28 +00:00
Merge branch 'master' into dialog-screen-battle
This commit is contained in:
commit
52abcf1c02
@ -10,7 +10,8 @@
|
|||||||
"file.lastUsedOpenFilter": "Fichiers de jeu de tuiles Tiled (*.tsx *.xml)",
|
"file.lastUsedOpenFilter": "Fichiers de jeu de tuiles Tiled (*.tsx *.xml)",
|
||||||
"fileStates": {
|
"fileStates": {
|
||||||
"": {
|
"": {
|
||||||
"scaleInDock": 1
|
"scaleInDock": 1,
|
||||||
|
"scaleInEditor": 1
|
||||||
},
|
},
|
||||||
"C:/Users/remi/AppData/Roaming/Tiled/#Tests": {
|
"C:/Users/remi/AppData/Roaming/Tiled/#Tests": {
|
||||||
"dynamicWrapping": true
|
"dynamicWrapping": true
|
||||||
@ -197,8 +198,8 @@
|
|||||||
"scale": 0.75,
|
"scale": 0.75,
|
||||||
"selectedLayer": 1,
|
"selectedLayer": 1,
|
||||||
"viewCenter": {
|
"viewCenter": {
|
||||||
"x": 640.6666666666667,
|
"x": 640,
|
||||||
"y": 640.6666666666666
|
"y": 640
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"desert.tmx#Desert": {
|
"desert.tmx#Desert": {
|
||||||
@ -212,7 +213,7 @@
|
|||||||
"scale": 1.5,
|
"scale": 1.5,
|
||||||
"selectedLayer": 1,
|
"selectedLayer": 1,
|
||||||
"viewCenter": {
|
"viewCenter": {
|
||||||
"x": 160.33333333333331,
|
"x": 160.66666666666669,
|
||||||
"y": 160.33333333333331
|
"y": 160.33333333333331
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -224,11 +225,11 @@
|
|||||||
"expandedObjectLayers": [
|
"expandedObjectLayers": [
|
||||||
9
|
9
|
||||||
],
|
],
|
||||||
"scale": 1,
|
"scale": 3,
|
||||||
"selectedLayer": 4,
|
"selectedLayer": 4,
|
||||||
"viewCenter": {
|
"viewCenter": {
|
||||||
"x": 320.5,
|
"x": 62.66666666666667,
|
||||||
"y": 159.5
|
"y": 172.83333333333331
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"test_couloir.tmx#Dungeon_Tileset": {
|
"test_couloir.tmx#Dungeon_Tileset": {
|
||||||
|
@ -8984,8 +8984,8 @@
|
|||||||
<layer id="2" name="floor" width="20" height="10">
|
<layer id="2" name="floor" width="20" height="10">
|
||||||
<data encoding="csv">
|
<data encoding="csv">
|
||||||
956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,
|
956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,
|
||||||
956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,
|
956,956,956,1113,1113,956,956,956,956,956,956,956,956,956,956,1113,1113,956,956,956,
|
||||||
1079,1079,1079,1079,1079,1079,1079,1079,1079,1079,1079,1079,1079,1079,1079,1079,1079,1079,1079,1079,
|
1079,1079,1079,1113,1113,1079,1079,1079,1079,1079,1079,1079,1079,1079,1079,1113,1113,1079,1079,1079,
|
||||||
1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,
|
1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,
|
||||||
1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,
|
1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,
|
||||||
1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,
|
1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,1113,
|
||||||
@ -9024,28 +9024,28 @@
|
|||||||
</data>
|
</data>
|
||||||
</layer>
|
</layer>
|
||||||
<objectgroup id="9" name="door">
|
<objectgroup id="9" name="door">
|
||||||
<object id="8" x="111" y="79">
|
<object id="8" x="112" y="49.3333">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="nextMap" value="test"/>
|
<property name="nextMap" value="test"/>
|
||||||
<property name="nextX" type="int" value="2"/>
|
<property name="nextX" type="int" value="2"/>
|
||||||
<property name="nextY" type="int" value="0"/>
|
<property name="nextY" type="int" value="0"/>
|
||||||
</properties>
|
</properties>
|
||||||
</object>
|
</object>
|
||||||
<object id="9" x="144" y="79">
|
<object id="9" x="144.667" y="49">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="nextMap" value="test"/>
|
<property name="nextMap" value="test"/>
|
||||||
<property name="nextX" type="int" value="2"/>
|
<property name="nextX" type="int" value="2"/>
|
||||||
<property name="nextY" type="int" value="0"/>
|
<property name="nextY" type="int" value="0"/>
|
||||||
</properties>
|
</properties>
|
||||||
</object>
|
</object>
|
||||||
<object id="10" x="496.5" y="78">
|
<object id="10" x="497.167" y="48">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="nextMap" value="test"/>
|
<property name="nextMap" value="test"/>
|
||||||
<property name="nextX" type="int" value="6"/>
|
<property name="nextX" type="int" value="6"/>
|
||||||
<property name="nextY" type="int" value="0"/>
|
<property name="nextY" type="int" value="0"/>
|
||||||
</properties>
|
</properties>
|
||||||
</object>
|
</object>
|
||||||
<object id="11" x="525.5" y="78">
|
<object id="11" x="526.167" y="48">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="nextMap" value="test"/>
|
<property name="nextMap" value="test"/>
|
||||||
<property name="nextX" type="int" value="6"/>
|
<property name="nextX" type="int" value="6"/>
|
||||||
|
@ -32,10 +32,9 @@ public abstract class Character extends Entity{
|
|||||||
|
|
||||||
protected int pv;
|
protected int pv;
|
||||||
|
|
||||||
public Character(String name, int x, int y, String img){
|
public Character(String name, int x, int y, String img, String map){
|
||||||
super(name, x, y);
|
super(name, x, y, map);
|
||||||
this.img = img;
|
this.img = img;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,12 +3,11 @@ package Entity;
|
|||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
|
||||||
public class Enemy extends Character{
|
public class Enemy extends Character{
|
||||||
private String map;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Enemy(String name, int x, int y, String img, String map) {
|
public Enemy(String name, int x, int y, String img, String map) {
|
||||||
super(name, x, y, img);
|
super(name, x, y, img, map);
|
||||||
//generate his text
|
//generate his text
|
||||||
|
|
||||||
this.map = map;
|
this.map = map;
|
||||||
@ -19,10 +18,6 @@ public class Enemy extends Character{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMap() {
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPosition(int x, int y, String map){
|
public void setPosition(int x, int y, String map){
|
||||||
position.set(x, y);
|
position.set(x, y);
|
||||||
this.map = map;
|
this.map = map;
|
||||||
|
@ -8,6 +8,7 @@ import ch.hevs.gdx2d.lib.interfaces.DrawableObject;
|
|||||||
|
|
||||||
public abstract class Entity implements DrawableObject {
|
public abstract class Entity implements DrawableObject {
|
||||||
protected String name;
|
protected String name;
|
||||||
|
protected String map;
|
||||||
|
|
||||||
Spritesheet ss;
|
Spritesheet ss;
|
||||||
|
|
||||||
@ -20,19 +21,17 @@ public abstract class Entity implements DrawableObject {
|
|||||||
|
|
||||||
protected boolean move = false;
|
protected boolean move = false;
|
||||||
|
|
||||||
public Entity(String name){
|
|
||||||
this(name, new Vector2(0,0));
|
public Entity(String name, int x, int y, String map){
|
||||||
|
this(name, new Vector2(SPRITE_WIDTH * x, SPRITE_HEIGHT * y), map);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entity(String name, int x, int y){
|
public Entity(String name, Vector2 initialPosition, String map){
|
||||||
this(name, new Vector2(SPRITE_WIDTH * x, SPRITE_HEIGHT * y));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Entity(String name, Vector2 initialPosition){
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
lastPosition = new Vector2(initialPosition);
|
lastPosition = new Vector2(initialPosition);
|
||||||
newPosition = new Vector2(initialPosition);
|
newPosition = new Vector2(initialPosition);
|
||||||
position = new Vector2(initialPosition);
|
position = new Vector2(initialPosition);
|
||||||
|
this.map = map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(){
|
public void init(){
|
||||||
@ -58,4 +57,8 @@ public abstract class Entity implements DrawableObject {
|
|||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getMap() {
|
||||||
|
return map;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package Entity;
|
package Entity;
|
||||||
|
|
||||||
|
import java.util.TreeMap;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import com.badlogic.gdx.Input;
|
import com.badlogic.gdx.Input;
|
||||||
@ -7,14 +8,17 @@ import com.badlogic.gdx.maps.tiled.TiledMapTile;
|
|||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
|
||||||
import Control.Controller;
|
import Control.Controller;
|
||||||
|
import Main.PokeMudry;
|
||||||
import Screen.ScreenMap;
|
import Screen.ScreenMap;
|
||||||
|
|
||||||
public class Player extends Character{
|
public class Player extends Character{
|
||||||
|
|
||||||
private int xp;
|
private int xp;
|
||||||
|
public Enemy lastEnemy = null;
|
||||||
|
public boolean frontOfEnemy = false;
|
||||||
|
|
||||||
public Player(int x, int y) {
|
public Player(int x, int y, String map) {
|
||||||
super("Player", x, y, "Character");
|
super("Player", x, y, "Character", map);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addXp(int xp){
|
public void addXp(int xp){
|
||||||
@ -29,25 +33,36 @@ public class Player extends Character{
|
|||||||
// Compute direction and next cell
|
// Compute direction and next cell
|
||||||
Vector<TiledMapTile> nextCell = new Vector<>();
|
Vector<TiledMapTile> nextCell = new Vector<>();
|
||||||
Player.Direction goalDirection = Player.Direction.NULL;
|
Player.Direction goalDirection = Player.Direction.NULL;
|
||||||
|
Vector2 nextPos = position;
|
||||||
|
|
||||||
if (c.keyStatus.get(Input.Keys.RIGHT)) {
|
if (c.keyStatus.get(Input.Keys.RIGHT)) {
|
||||||
goalDirection = Player.Direction.RIGHT;
|
goalDirection = Player.Direction.RIGHT;
|
||||||
nextCell = sm.getTile(getPosition(), 1, 0);
|
nextCell = sm.getTile(getPosition(), 1, 0);
|
||||||
|
nextPos.x+=sm.tileWidth;
|
||||||
} else if (c.keyStatus.get(Input.Keys.LEFT)) {
|
} else if (c.keyStatus.get(Input.Keys.LEFT)) {
|
||||||
goalDirection = Player.Direction.LEFT;
|
goalDirection = Player.Direction.LEFT;
|
||||||
nextCell = sm.getTile(getPosition(), -1, 0);
|
nextCell = sm.getTile(getPosition(), -1, 0);
|
||||||
|
nextPos.x-=sm.tileWidth;
|
||||||
} else if (c.keyStatus.get(Input.Keys.UP)) {
|
} else if (c.keyStatus.get(Input.Keys.UP)) {
|
||||||
goalDirection = Player.Direction.UP;
|
goalDirection = Player.Direction.UP;
|
||||||
nextCell = sm.getTile(getPosition(), 0, 1);
|
nextCell = sm.getTile(getPosition(), 0, 1);
|
||||||
|
nextPos.y+=sm.tileHeight;
|
||||||
} else if (c.keyStatus.get(Input.Keys.DOWN)) {
|
} else if (c.keyStatus.get(Input.Keys.DOWN)) {
|
||||||
goalDirection = Player.Direction.DOWN;
|
goalDirection = Player.Direction.DOWN;
|
||||||
nextCell = sm.getTile(getPosition(), 0, -1);
|
nextCell = sm.getTile(getPosition(), 0, -1);
|
||||||
|
nextPos.y-=sm.tileHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is the move valid ?
|
// Is the move valid ?
|
||||||
if (sm.isWalkable(nextCell)) {
|
if (sm.isWalkable(nextCell)) {
|
||||||
|
|
||||||
|
if (enemy(sm, nextPos)) {
|
||||||
|
//turn(goalDirection);
|
||||||
|
System.out.println("It's a enemy !!");
|
||||||
|
} else {
|
||||||
setSpeed(sm.getSpeed(nextCell));
|
setSpeed(sm.getSpeed(nextCell));
|
||||||
go(goalDirection);
|
go(goalDirection);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Face the wall
|
// Face the wall
|
||||||
turn(goalDirection);
|
turn(goalDirection);
|
||||||
@ -65,29 +80,31 @@ public class Player extends Character{
|
|||||||
} catch (Exception e) { }
|
} catch (Exception e) { }
|
||||||
ScreenMap.Door.reset();
|
ScreenMap.Door.reset();
|
||||||
if (nMap == null || x == null || y == null) return;
|
if (nMap == null || x == null || y == null) return;
|
||||||
sm.map = nMap;
|
map = nMap;
|
||||||
setPosition(x*sm.tileWidth, y*sm.tileHeight);
|
setPosition(x*sm.tileWidth, y*sm.tileHeight);
|
||||||
System.out.println("Go to: " + sm.map + " in " + x + " x " + y);
|
System.out.println("Go to: " + sm.map + " in " + x + " x " + y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean enemy() {
|
private boolean enemy(ScreenMap sm, Vector2 nextPos) {
|
||||||
//Vector<Enemy> enemies = PokeMudry.getEnemies;
|
Vector<Enemy> enemies = PokeMudry.getEnemies();
|
||||||
//for (Enemy enemy : enemies) {
|
for (Enemy enemy : enemies) {
|
||||||
|
boolean bMap = sm.map.equals(enemy.getMap());
|
||||||
//}
|
int pX = (int) nextPos.x/sm.tileWidth;
|
||||||
|
int pY = (int) nextPos.y/sm.tileHeight;
|
||||||
|
int eX = (int) enemy.position.x/sm.tileWidth;
|
||||||
|
int eY = (int) enemy.position.y/sm.tileHeight;
|
||||||
|
//System.out.println("Player: " + pX + " x " + pY + " - Enemy: " + eX + " x " + eY);
|
||||||
|
if(bMap && pX==eX && pY==eY) {
|
||||||
|
lastEnemy = enemy;
|
||||||
|
frontOfEnemy = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void move(int x, int y){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void move(Vector2 vMove){
|
|
||||||
move((int)vMove.x, (int)vMove.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void removedPv(int pv) {
|
protected void removedPv(int pv) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
@ -4,8 +4,8 @@ import ch.hevs.gdx2d.lib.GdxGraphics;
|
|||||||
|
|
||||||
public class Stuff extends Entity{
|
public class Stuff extends Entity{
|
||||||
|
|
||||||
public Stuff(String name) {
|
public Stuff(String name, int x, int y, String map) {
|
||||||
super(name);
|
super(name, x, y, map);
|
||||||
//TODO Auto-generated constructor stub
|
//TODO Auto-generated constructor stub
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,28 +2,22 @@ package Main;
|
|||||||
|
|
||||||
|
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import com.badlogic.gdx.Input;
|
import com.badlogic.gdx.Input;
|
||||||
|
|
||||||
import Control.Controller;
|
import Control.Controller;
|
||||||
import Entity.Enemy;
|
import Entity.Enemy;
|
||||||
import Entity.Entity;
|
import Entity.Entity;
|
||||||
|
import Screen.ScreenMap;
|
||||||
import Screen.ScreenPlayer;
|
import Screen.ScreenPlayer;
|
||||||
import ch.hevs.gdx2d.desktop.PortableApplication;
|
import ch.hevs.gdx2d.desktop.PortableApplication;
|
||||||
import ch.hevs.gdx2d.lib.GdxGraphics;
|
import ch.hevs.gdx2d.lib.GdxGraphics;
|
||||||
|
|
||||||
public class PokeMudry extends PortableApplication {
|
public class PokeMudry extends PortableApplication {
|
||||||
|
|
||||||
public final boolean ANDROID = false;
|
|
||||||
public final int PLAYERS = 1;
|
|
||||||
public static final int TIME = 10; // number of minutes for kill all enemy
|
|
||||||
|
|
||||||
public static final int HEIGHT = 800;
|
|
||||||
public static final int width = 800;
|
|
||||||
|
|
||||||
private ScreenPlayer sp;
|
private ScreenPlayer sp;
|
||||||
private Controller controller;
|
private Controller controller;
|
||||||
//private Player p1;
|
|
||||||
private static Vector<Enemy> enemies = new Vector<>();
|
private static Vector<Enemy> enemies = new Vector<>();
|
||||||
private static Vector<Entity> entities = new Vector<>();
|
private static Vector<Entity> entities = new Vector<>();
|
||||||
|
|
||||||
@ -48,15 +42,11 @@ public class PokeMudry extends PortableApplication {
|
|||||||
controller.init();
|
controller.init();
|
||||||
entities.add((Entity) sp.p);
|
entities.add((Entity) sp.p);
|
||||||
enemies.add(new Enemy("Mudry", 10, 15, "lumberjack_sheet32", "desert"));
|
enemies.add(new Enemy("Mudry", 10, 15, "lumberjack_sheet32", "desert"));
|
||||||
enemies.add(new Enemy("Pignat", 12, 15, "lumberjack_sheet32", "desert"));
|
enemies.add(new Enemy("Pignat", 5, 1, "lumberjack_sheet32", "test"));
|
||||||
|
|
||||||
for (Enemy enemy : enemies) {
|
for (Enemy enemy : enemies) { entities.add(enemy); }
|
||||||
entities.add(enemy);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Entity entity : entities) {
|
for (Entity entity : entities) { entity.init(); }
|
||||||
entity.init();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -64,9 +54,20 @@ public class PokeMudry extends PortableApplication {
|
|||||||
g.clear();
|
g.clear();
|
||||||
sp.p.manageEntity(sp.sm, controller);
|
sp.p.manageEntity(sp.sm, controller);
|
||||||
sp.render(g);
|
sp.render(g);
|
||||||
|
System.out.println(sp.screenManager.getActiveScreen().getClass());
|
||||||
|
//System.out.println(ScreenMap.class);
|
||||||
for (Entity entity : entities) {
|
for (Entity entity : entities) {
|
||||||
|
|
||||||
|
if (entity.getMap().equals(sp.sm.map) && sp.screenManager.getActiveScreen().getClass().equals(ScreenMap.class))
|
||||||
entity.graphicRender(g);
|
entity.graphicRender(g);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sp.p.frontOfEnemy && sp.screenManager.getActiveScreen().getClass().equals(ScreenMap.class)){
|
||||||
|
sp.e = sp.p.lastEnemy;
|
||||||
|
System.out.println("switch screen");
|
||||||
|
sp.screenManager.activateNextScreen();
|
||||||
|
g.resetCamera();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -79,8 +80,6 @@ public class PokeMudry extends PortableApplication {
|
|||||||
case Input.Keys.Z:
|
case Input.Keys.Z:
|
||||||
if (sp.sm.zoom == 1.0) {
|
if (sp.sm.zoom == 1.0) {
|
||||||
sp.sm.zoom = 0.5f;
|
sp.sm.zoom = 0.5f;
|
||||||
} else if (sp.sm.zoom == 0.5) {
|
|
||||||
sp.sm.zoom = 0.25f;
|
|
||||||
} else {
|
} else {
|
||||||
sp.sm.zoom = 1;
|
sp.sm.zoom = 1;
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@ package Main;
|
|||||||
|
|
||||||
public class Settings {
|
public class Settings {
|
||||||
|
|
||||||
public final boolean ANDROID = false;
|
public static final boolean ANDROID = false;
|
||||||
public final int PLAYERS = 1;
|
public static final int PLAYERS = 1;
|
||||||
public static final int TIME = 10; // number of minutes for kill all enemy
|
public static final int TIME = 10; // number of minutes for kill all enemy
|
||||||
|
|
||||||
public static final int SIDE = 800;
|
public static final int SIDE = 800;
|
||||||
|
@ -4,15 +4,14 @@ import ch.hevs.gdx2d.lib.ScreenManager;
|
|||||||
|
|
||||||
public class ManagerOfScreen extends ScreenManager{
|
public class ManagerOfScreen extends ScreenManager{
|
||||||
ManagerOfScreen(){
|
ManagerOfScreen(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ScreenMap getScreenMap(){
|
public ScreenMap getScreenMap(){
|
||||||
this.activateScreen(0);
|
this.activateScreen(0);
|
||||||
return (ScreenMap)this.getActiveScreen();
|
return (ScreenMap)this.getActiveScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
ScreenBattle getScreenBattle(){
|
public ScreenBattle getScreenBattle(){
|
||||||
this.activateScreen(1);
|
this.activateScreen(1);
|
||||||
return (ScreenBattle)this.getActiveScreen();
|
return (ScreenBattle)this.getActiveScreen();
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,11 @@ public class ScreenBattle extends RenderingScreen{
|
|||||||
private static int EDGE = 10;
|
private static int EDGE = 10;
|
||||||
private static int HEIGHT_DIALOG = Settings.SIDE / 3;
|
private static int HEIGHT_DIALOG = Settings.SIDE / 3;
|
||||||
private static int WIDTH_DIALOG = Settings.SIDE - 2*EDGE;
|
private static int WIDTH_DIALOG = Settings.SIDE - 2*EDGE;
|
||||||
|
private Enemy e;
|
||||||
|
|
||||||
|
private boolean attackOn;
|
||||||
|
private int numAttack =0;
|
||||||
|
|
||||||
|
|
||||||
private BitmapFont optimus40;
|
private BitmapFont optimus40;
|
||||||
|
|
||||||
@ -86,6 +91,13 @@ public class ScreenBattle extends RenderingScreen{
|
|||||||
//dialog
|
//dialog
|
||||||
g.drawString(15, 245 ,lineDialog , optimus40);
|
g.drawString(15, 245 ,lineDialog , optimus40);
|
||||||
|
|
||||||
|
}
|
||||||
|
public void setEnemy(Enemy e) {
|
||||||
|
this.e = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void displayEnemy(Enemy e){
|
||||||
|
// stock his speech
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayPlayer(Player p){
|
public void displayPlayer(Player p){
|
||||||
|
@ -27,12 +27,13 @@ public class ScreenMap extends RenderingScreen{
|
|||||||
private MapObjects doors;
|
private MapObjects doors;
|
||||||
Map<String,TiledMap> tMap = new TreeMap<String,TiledMap>();
|
Map<String,TiledMap> tMap = new TreeMap<String,TiledMap>();
|
||||||
Map<String,TiledMapRenderer> tMapRenderer = new TreeMap<String,TiledMapRenderer>();
|
Map<String,TiledMapRenderer> tMapRenderer = new TreeMap<String,TiledMapRenderer>();
|
||||||
public String map = "desert";
|
public String map = "test_couloir";
|
||||||
public float zoom;
|
public float zoom;
|
||||||
private int width;
|
private int width;
|
||||||
public int tileWidth;
|
public int tileWidth;
|
||||||
private int height;
|
private int height;
|
||||||
public int tileHeight;
|
public int tileHeight;
|
||||||
|
private Player player;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -47,6 +48,8 @@ public class ScreenMap extends RenderingScreen{
|
|||||||
// Set initial zoom
|
// Set initial zoom
|
||||||
zoom = 1;
|
zoom = 1;
|
||||||
|
|
||||||
|
try { map = player.getMap(); } catch (Exception e) {}
|
||||||
|
|
||||||
// create map
|
// create map
|
||||||
createMap("test");
|
createMap("test");
|
||||||
createMap("test_couloir");
|
createMap("test_couloir");
|
||||||
@ -57,6 +60,9 @@ public class ScreenMap extends RenderingScreen{
|
|||||||
public void onGraphicRender(GdxGraphics g) {
|
public void onGraphicRender(GdxGraphics g) {
|
||||||
|
|
||||||
tiledLayer.clear();
|
tiledLayer.clear();
|
||||||
|
|
||||||
|
try { map = player.getMap(); } catch (Exception e) {}
|
||||||
|
|
||||||
for (int i = 0; i < 50; i++) {
|
for (int i = 0; i < 50; i++) {
|
||||||
try { tiledLayer.add((TiledMapTileLayer) tMap.get(map).getLayers().get(i)); } catch (Exception e) { }
|
try { tiledLayer.add((TiledMapTileLayer) tMap.get(map).getLayers().get(i)); } catch (Exception e) { }
|
||||||
}
|
}
|
||||||
@ -73,18 +79,19 @@ public class ScreenMap extends RenderingScreen{
|
|||||||
|
|
||||||
|
|
||||||
// Render the tileMap
|
// Render the tileMap
|
||||||
|
try {
|
||||||
|
g.zoom(zoom);
|
||||||
|
g.moveCamera(player.getPosition().x, player.getPosition().y, width * tileWidth, height * tileHeight);
|
||||||
|
} catch (Exception e) {
|
||||||
|
//TODO: handle exception
|
||||||
|
}
|
||||||
|
|
||||||
tMapRenderer.get(map).setView(g.getCamera());
|
tMapRenderer.get(map).setView(g.getCamera());
|
||||||
tMapRenderer.get(map).render();
|
tMapRenderer.get(map).render();
|
||||||
|
|
||||||
g.drawFPS();
|
g.drawFPS();
|
||||||
}
|
}
|
||||||
|
|
||||||
void camera(GdxGraphics g, Player player){
|
|
||||||
g.zoom(zoom);
|
|
||||||
g.moveCamera(player.getPosition().x, player.getPosition().y, width * tileWidth, height * tileHeight);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Vector<TiledMapTile> getTile(Vector2 position, int offsetX, int offsetY) {
|
public Vector<TiledMapTile> getTile(Vector2 position, int offsetX, int offsetY) {
|
||||||
Vector<TiledMapTile> tiles = new Vector<>();
|
Vector<TiledMapTile> tiles = new Vector<>();
|
||||||
@ -165,4 +172,8 @@ public class ScreenMap extends RenderingScreen{
|
|||||||
nextY = null;
|
nextY = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPlayer(Player p) {
|
||||||
|
player = p;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,28 @@
|
|||||||
package Screen;
|
package Screen;
|
||||||
|
|
||||||
|
import Entity.Enemy;
|
||||||
import Entity.Player;
|
import Entity.Player;
|
||||||
import ch.hevs.gdx2d.lib.GdxGraphics;
|
import ch.hevs.gdx2d.lib.GdxGraphics;
|
||||||
|
|
||||||
public class ScreenPlayer {
|
public class ScreenPlayer {
|
||||||
public ManagerOfScreen screenManager = new ManagerOfScreen();
|
public ManagerOfScreen screenManager = new ManagerOfScreen();
|
||||||
public Player p;
|
public Player p;
|
||||||
|
public Enemy e;
|
||||||
public ScreenMap sm;
|
public ScreenMap sm;
|
||||||
|
public ScreenBattle sb;
|
||||||
|
|
||||||
public void init(){
|
public void init(){
|
||||||
|
p = new Player(8, 15, "desert");
|
||||||
screenManager.registerScreen(ScreenMap.class);
|
screenManager.registerScreen(ScreenMap.class);
|
||||||
screenManager.registerScreen(ScreenBattle.class);
|
screenManager.registerScreen(ScreenBattle.class);
|
||||||
|
sb = screenManager.getScreenBattle();
|
||||||
sm = screenManager.getScreenMap();
|
sm = screenManager.getScreenMap();
|
||||||
p = new Player(8, 15);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render(GdxGraphics g){
|
public void render(GdxGraphics g){
|
||||||
|
sb.setEnemy(e);
|
||||||
|
sm.setPlayer(p);
|
||||||
screenManager.render(g);
|
screenManager.render(g);
|
||||||
sm.camera(g, p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user