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

Merge pull request #14 from Klagarge:polish

Polish
This commit is contained in:
Rémi Heredero
2022-06-12 12:37:39 +02:00
committed by GitHub
7 changed files with 71 additions and 24 deletions

View File

@ -32,6 +32,14 @@ public abstract class Character extends Entity{
protected int pv;
/**
* Create a character on the world
* @param name Name of the new character
* @param x initial x position
* @param y initial y position
* @param img the name of the spritesheet for this character
* @param map the initial map
*/
public Character(String name, int x, int y, String img, String map){
super(name, x, y, map);
this.img = img;
@ -87,7 +95,7 @@ public abstract class Character extends Entity{
}
/**
* @param speed The new speed of the hero.
* @param speed The new speed of the character.
*/
public void setSpeed(float speed){
this.speed = speed;

View File

@ -22,10 +22,23 @@ public abstract class Entity implements DrawableObject {
protected boolean move = false;
/**
* Create an entity
* @param name The name of this new entity
* @param x The initial x position
* @param y The initial y position
* @param map The initial map
*/
public Entity(String name, int x, int y, String map){
this(name, new Vector2(SPRITE_WIDTH * x, SPRITE_HEIGHT * y), map);
}
/**
* Create an entity
* @param name The name of this new entity
* @param initialPosition The initial position by a Vector2
* @param map The initial map
*/
public Entity(String name, Vector2 initialPosition, String map){
this.name = name;
lastPosition = new Vector2(initialPosition);

View File

@ -1,6 +1,5 @@
package Entity;
import java.util.TreeMap;
import java.util.Vector;
import com.badlogic.gdx.Input;
@ -57,7 +56,7 @@ public class Player extends Character{
if (sm.isWalkable(nextCell)) {
if (enemy(sm, nextPos)) {
//turn(goalDirection);
turn(goalDirection);
System.out.println("It's a enemy !!");
} else {
setSpeed(sm.getSpeed(nextCell));
@ -95,7 +94,7 @@ public class Player extends Character{
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;