mirror of
https://github.com/Klagarge/PokeHES.git
synced 2024-11-26 19:13:27 +00:00
Merge pull request #24 from Klagarge:bug-fix-camera-jump
fix bug !!! (hallelujah)
This commit is contained in:
commit
a4b760fe66
@ -14,10 +14,10 @@ public class Player extends Character{
|
||||
|
||||
private int xp;
|
||||
public Enemy lastEnemy = null;
|
||||
public boolean frontOfEnemy = false;
|
||||
public boolean onEnemy = false;
|
||||
|
||||
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){
|
||||
@ -32,7 +32,7 @@ public class Player extends Character{
|
||||
// Compute direction and next cell
|
||||
Vector<TiledMapTile> nextCell = new Vector<>();
|
||||
Player.Direction goalDirection = Player.Direction.NULL;
|
||||
Vector2 nextPos = position;
|
||||
Vector2 nextPos = new Vector2(position);
|
||||
|
||||
if (c.keyStatus.get(Input.Keys.RIGHT)) {
|
||||
goalDirection = Player.Direction.RIGHT;
|
||||
@ -98,7 +98,7 @@ public class Player extends Character{
|
||||
|
||||
if(bMap && pX==eX && pY==eY) {
|
||||
lastEnemy = enemy;
|
||||
frontOfEnemy = true;
|
||||
onEnemy = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public class PokeMudry extends PortableApplication {
|
||||
if(onMapScreen) sp.p.manageEntity(sp.sm, controller);
|
||||
|
||||
// Switch screen
|
||||
if (sp.p.frontOfEnemy && onMapScreen){
|
||||
if (sp.p.onEnemy && onMapScreen){
|
||||
sp.e = sp.p.lastEnemy;
|
||||
sp.sb = sp.screenManager.getScreenBattle();
|
||||
sp.b = new Battle(sp.e);
|
||||
|
@ -59,19 +59,24 @@ public class ScreenMap extends RenderingScreen{
|
||||
|
||||
tiledLayer.clear();
|
||||
|
||||
// Get actual map of the player
|
||||
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) { }
|
||||
}
|
||||
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);
|
||||
width = tl.getWidth();
|
||||
tileWidth = (int) tl.getTileWidth();
|
||||
height = tl.getHeight();
|
||||
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 {
|
||||
doors = tMap.get(map).getLayers().get("door").getObjects();
|
||||
} catch (Exception e) { doors = null; }
|
||||
@ -79,8 +84,7 @@ public class ScreenMap extends RenderingScreen{
|
||||
|
||||
// Render the tileMap
|
||||
g.zoom(zoom);
|
||||
try {g.moveCamera(player.getPosition().x, player.getPosition().y, width * tileWidth, height * tileHeight);}
|
||||
catch (Exception e) {System.out.println("Fail to move camera");}
|
||||
g.moveCamera((int)player.getPosition().x, (int)player.getPosition().y, width * tileWidth, height * tileHeight);
|
||||
|
||||
tMapRenderer.get(map).setView(g.getCamera());
|
||||
tMapRenderer.get(map).render();
|
||||
|
Loading…
Reference in New Issue
Block a user