mirror of
https://github.com/Klagarge/PokeHES.git
synced 2024-11-23 01:43:28 +00:00
enemy integration done, but big bug when move
This commit is contained in:
parent
1466ba041a
commit
56d57ca17c
@ -10,7 +10,8 @@
|
||||
"file.lastUsedOpenFilter": "Fichiers de jeu de tuiles Tiled (*.tsx *.xml)",
|
||||
"fileStates": {
|
||||
"": {
|
||||
"scaleInDock": 1
|
||||
"scaleInDock": 1,
|
||||
"scaleInEditor": 1
|
||||
},
|
||||
"C:/Users/remi/AppData/Roaming/Tiled/#Tests": {
|
||||
"dynamicWrapping": true
|
||||
@ -212,8 +213,8 @@
|
||||
"scale": 1.5,
|
||||
"selectedLayer": 1,
|
||||
"viewCenter": {
|
||||
"x": 159.33333333333331,
|
||||
"y": 160.66666666666663
|
||||
"x": 160.66666666666669,
|
||||
"y": 160.33333333333331
|
||||
}
|
||||
},
|
||||
"test.tmx#test": {
|
||||
@ -224,11 +225,11 @@
|
||||
"expandedObjectLayers": [
|
||||
9
|
||||
],
|
||||
"scale": 1,
|
||||
"scale": 3,
|
||||
"selectedLayer": 4,
|
||||
"viewCenter": {
|
||||
"x": 351,
|
||||
"y": 196
|
||||
"x": 62.66666666666667,
|
||||
"y": 172.83333333333331
|
||||
}
|
||||
},
|
||||
"test_couloir.tmx#Dungeon_Tileset": {
|
||||
|
@ -8984,8 +8984,8 @@
|
||||
<layer id="2" name="floor" width="20" height="10">
|
||||
<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,
|
||||
1079,1079,1079,1079,1079,1079,1079,1079,1079,1079,1079,1079,1079,1079,1079,1079,1079,1079,1079,1079,
|
||||
956,956,956,1113,1113,956,956,956,956,956,956,956,956,956,956,1113,1113,956,956,956,
|
||||
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,
|
||||
@ -9024,28 +9024,28 @@
|
||||
</data>
|
||||
</layer>
|
||||
<objectgroup id="9" name="door">
|
||||
<object id="8" x="111" y="79">
|
||||
<object id="8" x="112" y="49.3333">
|
||||
<properties>
|
||||
<property name="nextMap" value="test"/>
|
||||
<property name="nextX" type="int" value="2"/>
|
||||
<property name="nextY" type="int" value="0"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="9" x="144" y="79">
|
||||
<object id="9" x="144.667" y="49">
|
||||
<properties>
|
||||
<property name="nextMap" value="test"/>
|
||||
<property name="nextX" type="int" value="2"/>
|
||||
<property name="nextY" type="int" value="0"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="10" x="496.5" y="78">
|
||||
<object id="10" x="497.167" y="48">
|
||||
<properties>
|
||||
<property name="nextMap" value="test"/>
|
||||
<property name="nextX" type="int" value="6"/>
|
||||
<property name="nextY" type="int" value="0"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="11" x="525.5" y="78">
|
||||
<object id="11" x="526.167" y="48">
|
||||
<properties>
|
||||
<property name="nextMap" value="test"/>
|
||||
<property name="nextX" type="int" value="6"/>
|
||||
|
@ -32,10 +32,9 @@ public abstract class Character extends Entity{
|
||||
|
||||
protected int pv;
|
||||
|
||||
public Character(String name, int x, int y, String img){
|
||||
super(name, x, y);
|
||||
public Character(String name, int x, int y, String img, String map){
|
||||
super(name, x, y, map);
|
||||
this.img = img;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,16 +5,14 @@ import com.badlogic.gdx.math.Vector2;
|
||||
import Text.TextEnemy;
|
||||
|
||||
public class Enemy extends Character{
|
||||
private String map;
|
||||
|
||||
public TextEnemy textEnemy;
|
||||
|
||||
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
|
||||
this.textEnemy = new TextEnemy("enemi"); //TODO should be name
|
||||
textEnemy.generateText();
|
||||
this.map = map;
|
||||
|
||||
turn(Character.Direction.DOWN);
|
||||
//generate the vector of fight
|
||||
@ -22,10 +20,6 @@ public class Enemy extends Character{
|
||||
|
||||
}
|
||||
|
||||
public String getMap() {
|
||||
return map;
|
||||
}
|
||||
|
||||
public void setPosition(int x, int y, String map){
|
||||
position.set(x, y);
|
||||
this.map = map;
|
||||
|
@ -8,6 +8,7 @@ import ch.hevs.gdx2d.lib.interfaces.DrawableObject;
|
||||
|
||||
public abstract class Entity implements DrawableObject {
|
||||
protected String name;
|
||||
protected String map;
|
||||
|
||||
Spritesheet ss;
|
||||
|
||||
@ -20,19 +21,17 @@ public abstract class Entity implements DrawableObject {
|
||||
|
||||
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){
|
||||
this(name, new Vector2(SPRITE_WIDTH * x, SPRITE_HEIGHT * y));
|
||||
}
|
||||
|
||||
public Entity(String name, Vector2 initialPosition){
|
||||
public Entity(String name, Vector2 initialPosition, String map){
|
||||
this.name = name;
|
||||
lastPosition = new Vector2(initialPosition);
|
||||
newPosition = new Vector2(initialPosition);
|
||||
position = new Vector2(initialPosition);
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
public void init(){
|
||||
@ -58,4 +57,8 @@ public abstract class Entity implements DrawableObject {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getMap() {
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ public class Player extends Character{
|
||||
|
||||
private int xp;
|
||||
|
||||
public Player(int x, int y) {
|
||||
super("Player", x, y, "Character");
|
||||
public Player(int x, int y, String map) {
|
||||
super("Player", x, y, "lumberjack_sheet32", map);
|
||||
}
|
||||
|
||||
public void addXp(int xp){
|
||||
@ -52,6 +52,7 @@ public class Player extends Character{
|
||||
|
||||
// Is the move valid ?
|
||||
if (sm.isWalkable(nextCell)) {
|
||||
|
||||
if (enemy(sm, nextPos)) {
|
||||
System.out.println("It's a enemy !!");
|
||||
} else {
|
||||
@ -75,7 +76,7 @@ public class Player extends Character{
|
||||
} catch (Exception e) { }
|
||||
ScreenMap.Door.reset();
|
||||
if (nMap == null || x == null || y == null) return;
|
||||
sm.map = nMap;
|
||||
map = nMap;
|
||||
setPosition(x*sm.tileWidth, y*sm.tileHeight);
|
||||
System.out.println("Go to: " + sm.map + " in " + x + " x " + y);
|
||||
}
|
||||
|
@ -4,8 +4,8 @@ import ch.hevs.gdx2d.lib.GdxGraphics;
|
||||
|
||||
public class Stuff extends Entity{
|
||||
|
||||
public Stuff(String name) {
|
||||
super(name);
|
||||
public Stuff(String name, int x, int y, String map) {
|
||||
super(name, x, y, map);
|
||||
//TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ public class PokeMudry extends PortableApplication {
|
||||
sp.p.manageEntity(sp.sm, controller);
|
||||
sp.render(g);
|
||||
for (Entity entity : entities) {
|
||||
entity.graphicRender(g);
|
||||
if (entity.getMap().equals(sp.sm.map)) entity.graphicRender(g);
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,8 +71,6 @@ public class PokeMudry extends PortableApplication {
|
||||
case Input.Keys.Z:
|
||||
if (sp.sm.zoom == 1.0) {
|
||||
sp.sm.zoom = 0.5f;
|
||||
} else if (sp.sm.zoom == 0.5) {
|
||||
sp.sm.zoom = 0.25f;
|
||||
} else {
|
||||
sp.sm.zoom = 1;
|
||||
}
|
||||
|
@ -27,12 +27,13 @@ public class ScreenMap extends RenderingScreen{
|
||||
private MapObjects doors;
|
||||
Map<String,TiledMap> tMap = new TreeMap<String,TiledMap>();
|
||||
Map<String,TiledMapRenderer> tMapRenderer = new TreeMap<String,TiledMapRenderer>();
|
||||
public String map = "desert";
|
||||
public String map = "test_couloir";
|
||||
public float zoom;
|
||||
private int width;
|
||||
public int tileWidth;
|
||||
private int height;
|
||||
public int tileHeight;
|
||||
private Player player;
|
||||
|
||||
|
||||
|
||||
@ -47,6 +48,8 @@ public class ScreenMap extends RenderingScreen{
|
||||
// Set initial zoom
|
||||
zoom = 1;
|
||||
|
||||
try { map = player.getMap(); } catch (Exception e) {}
|
||||
|
||||
// create map
|
||||
createMap("test");
|
||||
createMap("test_couloir");
|
||||
@ -57,6 +60,9 @@ public class ScreenMap extends RenderingScreen{
|
||||
public void onGraphicRender(GdxGraphics g) {
|
||||
|
||||
tiledLayer.clear();
|
||||
|
||||
try { map = player.getMap(); } catch (Exception e) {}
|
||||
|
||||
for (int i = 0; i < 50; i++) {
|
||||
try { tiledLayer.add((TiledMapTileLayer) tMap.get(map).getLayers().get(i)); } catch (Exception e) { }
|
||||
}
|
||||
@ -73,18 +79,14 @@ public class ScreenMap extends RenderingScreen{
|
||||
|
||||
|
||||
// Render the tileMap
|
||||
g.zoom(zoom);
|
||||
g.moveCamera(player.getPosition().x, player.getPosition().y, width * tileWidth, height * tileHeight);
|
||||
tMapRenderer.get(map).setView(g.getCamera());
|
||||
tMapRenderer.get(map).render();
|
||||
|
||||
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) {
|
||||
Vector<TiledMapTile> tiles = new Vector<>();
|
||||
@ -165,4 +167,8 @@ public class ScreenMap extends RenderingScreen{
|
||||
nextY = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setPlayer(Player p) {
|
||||
player = p;
|
||||
}
|
||||
}
|
||||
|
@ -8,17 +8,16 @@ public class ScreenPlayer {
|
||||
public Player p;
|
||||
public ScreenMap sm;
|
||||
|
||||
|
||||
public void init(){
|
||||
p = new Player(8, 15, "desert");
|
||||
screenManager.registerScreen(ScreenMap.class);
|
||||
screenManager.registerScreen(ScreenBattle.class);
|
||||
sm = screenManager.getScreenMap();
|
||||
p = new Player(8, 15);
|
||||
}
|
||||
|
||||
public void render(GdxGraphics g){
|
||||
sm.setPlayer(p);
|
||||
screenManager.render(g);
|
||||
sm.camera(g, p);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user