1
0
mirror of https://github.com/Klagarge/PokeHES.git synced 2025-07-07 17:01:10 +00:00

enemy integration done, but big bug when move

This commit is contained in:
2022-06-10 16:39:50 +02:00
parent 1466ba041a
commit 56d57ca17c
10 changed files with 48 additions and 47 deletions

View File

@ -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

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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
}