mirror of
https://github.com/Klagarge/PokeHES.git
synced 2024-11-26 19:13:27 +00:00
fix bug !!! (hallelujah)
This commit is contained in:
parent
6d71baa535
commit
e71d23dd81
@ -14,10 +14,10 @@ public class Player extends Character{
|
|||||||
|
|
||||||
private int xp;
|
private int xp;
|
||||||
public Enemy lastEnemy = null;
|
public Enemy lastEnemy = null;
|
||||||
public boolean frontOfEnemy = false;
|
public boolean onEnemy = false;
|
||||||
|
|
||||||
public Player(int x, int y, String map) {
|
public Player(int x, int y, String map) {
|
||||||
super("Player", x, y, "Character", map);
|
super("Player", x, y, "character", map);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addXp(int xp){
|
public void addXp(int xp){
|
||||||
@ -32,7 +32,7 @@ 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;
|
Vector2 nextPos = new Vector2(position);
|
||||||
|
|
||||||
if (c.keyStatus.get(Input.Keys.RIGHT)) {
|
if (c.keyStatus.get(Input.Keys.RIGHT)) {
|
||||||
goalDirection = Player.Direction.RIGHT;
|
goalDirection = Player.Direction.RIGHT;
|
||||||
@ -98,7 +98,7 @@ public class Player extends Character{
|
|||||||
|
|
||||||
if(bMap && pX==eX && pY==eY) {
|
if(bMap && pX==eX && pY==eY) {
|
||||||
lastEnemy = enemy;
|
lastEnemy = enemy;
|
||||||
frontOfEnemy = true;
|
onEnemy = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public class PokeMudry extends PortableApplication {
|
|||||||
if(onMapScreen) sp.p.manageEntity(sp.sm, controller);
|
if(onMapScreen) sp.p.manageEntity(sp.sm, controller);
|
||||||
|
|
||||||
// Switch screen
|
// Switch screen
|
||||||
if (sp.p.frontOfEnemy && onMapScreen){
|
if (sp.p.onEnemy && onMapScreen){
|
||||||
sp.e = sp.p.lastEnemy;
|
sp.e = sp.p.lastEnemy;
|
||||||
sp.sb = sp.screenManager.getScreenBattle();
|
sp.sb = sp.screenManager.getScreenBattle();
|
||||||
sp.b = new Battle(sp.e);
|
sp.b = new Battle(sp.e);
|
||||||
|
@ -59,19 +59,24 @@ public class ScreenMap extends RenderingScreen{
|
|||||||
|
|
||||||
tiledLayer.clear();
|
tiledLayer.clear();
|
||||||
|
|
||||||
|
// Get actual map of the player
|
||||||
try { map = player.getMap(); } catch (Exception e) { System.out.println("error for get map");}
|
try { map = player.getMap(); } catch (Exception e) { System.out.println("error for get map");}
|
||||||
|
|
||||||
for (int i = 0; i < 50; i++) {
|
// Get all layers on the current map
|
||||||
|
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) { }
|
||||||
}
|
}
|
||||||
if (tiledLayer.size() <= 0) System.out.println("TiledLayer empty !!!");
|
|
||||||
|
// Get heigh and width of tiles and the size of the tiles
|
||||||
TiledMapTileLayer tl = tiledLayer.get(0);
|
TiledMapTileLayer tl = tiledLayer.get(0);
|
||||||
width = tl.getWidth();
|
width = tl.getWidth();
|
||||||
tileWidth = (int) tl.getTileWidth();
|
tileWidth = (int) tl.getTileWidth();
|
||||||
height = tl.getHeight();
|
height = tl.getHeight();
|
||||||
tileHeight = (int) tl.getTileHeight();
|
tileHeight = (int) tl.getTileHeight();
|
||||||
|
|
||||||
//System.out.println(width + " x " + height + " - " + tileWidth + " x " + tileHeight);
|
// System.out.println(width + " x " + height + " - " + tileWidth + " x " + tileHeight);
|
||||||
|
|
||||||
|
// Get all doors on the current map
|
||||||
try {
|
try {
|
||||||
doors = tMap.get(map).getLayers().get("door").getObjects();
|
doors = tMap.get(map).getLayers().get("door").getObjects();
|
||||||
} catch (Exception e) { doors = null; }
|
} catch (Exception e) { doors = null; }
|
||||||
@ -79,8 +84,7 @@ public class ScreenMap extends RenderingScreen{
|
|||||||
|
|
||||||
// Render the tileMap
|
// Render the tileMap
|
||||||
g.zoom(zoom);
|
g.zoom(zoom);
|
||||||
try {g.moveCamera(player.getPosition().x, player.getPosition().y, width * tileWidth, height * tileHeight);}
|
g.moveCamera((int)player.getPosition().x, (int)player.getPosition().y, width * tileWidth, height * tileHeight);
|
||||||
catch (Exception e) {System.out.println("Fail to move camera");}
|
|
||||||
|
|
||||||
tMapRenderer.get(map).setView(g.getCamera());
|
tMapRenderer.get(map).setView(g.getCamera());
|
||||||
tMapRenderer.get(map).render();
|
tMapRenderer.get(map).render();
|
||||||
|
Loading…
Reference in New Issue
Block a user