mirror of
				https://github.com/Klagarge/PokeHES.git
				synced 2025-10-31 03:39:16 +00:00 
			
		
		
		
	done
This commit is contained in:
		| @@ -1,20 +1,78 @@ | ||||
| package Entity; | ||||
|  | ||||
| import java.util.Vector; | ||||
|  | ||||
| import com.badlogic.gdx.Input; | ||||
| import com.badlogic.gdx.maps.tiled.TiledMapTile; | ||||
| import com.badlogic.gdx.math.Vector2; | ||||
|  | ||||
| import Control.Controller; | ||||
| import Screen.ScreenMap; | ||||
|  | ||||
| public class Player extends Character{ | ||||
|  | ||||
|     private int xp; | ||||
|  | ||||
|     public Player(String name) { | ||||
|         super(name); | ||||
|         //TODO Auto-generated constructor stub | ||||
|     public Player(int x, int y) { | ||||
|         super("Player", x, y, "lumberjack_sheet32"); | ||||
|     } | ||||
|  | ||||
|     public void addXp(int xp){ | ||||
|  | ||||
|     } | ||||
|  | ||||
|     public void manageEntity(ScreenMap sm, Controller c) { | ||||
|  | ||||
| 		// Do nothing if hero is already moving | ||||
| 		if (!isMoving()) { | ||||
|  | ||||
| 			// Compute direction and next cell | ||||
| 			Vector<TiledMapTile> nextCell = new Vector<>(); | ||||
| 			Player.Direction goalDirection = Player.Direction.NULL; | ||||
|  | ||||
| 			if (c.keyStatus.get(Input.Keys.RIGHT)) { | ||||
| 				goalDirection = Player.Direction.RIGHT; | ||||
| 				nextCell = sm.getTile(getPosition(), 1, 0); | ||||
| 			} else if (c.keyStatus.get(Input.Keys.LEFT)) { | ||||
| 				goalDirection = Player.Direction.LEFT; | ||||
| 				nextCell = sm.getTile(getPosition(), -1, 0); | ||||
| 			} else if (c.keyStatus.get(Input.Keys.UP)) { | ||||
| 				goalDirection = Player.Direction.UP; | ||||
| 				nextCell = sm.getTile(getPosition(), 0, 1); | ||||
| 			} else if (c.keyStatus.get(Input.Keys.DOWN)) { | ||||
| 				goalDirection = Player.Direction.DOWN; | ||||
| 				nextCell = sm.getTile(getPosition(), 0, -1); | ||||
| 			} | ||||
|  | ||||
| 			// Is the move valid ? | ||||
| 			if (sm.isWalkable(nextCell)) { | ||||
| 				// Go | ||||
| 				setSpeed(sm.getSpeed(nextCell)); | ||||
| 				go(goalDirection); | ||||
| 			} else { | ||||
| 				// Face the wall | ||||
| 				turn(goalDirection); | ||||
| 			} | ||||
|  | ||||
| 			 | ||||
| 			if(sm.isDoor(getPosition())){ | ||||
| 				String nMap = null; | ||||
| 				Integer x = null; | ||||
| 				Integer y = null; | ||||
| 				try { | ||||
| 					nMap = ScreenMap.Door.nextMap; | ||||
| 					x = ScreenMap.Door.nextX; | ||||
| 					y = ScreenMap.Door.nextY; | ||||
| 				} catch (Exception e) { } | ||||
| 				ScreenMap.Door.reset(); | ||||
| 				if (nMap == null || x == null || y == null) return; | ||||
| 				sm.map = nMap; | ||||
| 				setPosition(x*sm.tileWidth, y*sm.tileHeight); | ||||
| 				System.out.println("Go to: " + sm.map + " in " + x + " x " + y); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
|     public void move(int x, int y){ | ||||
|  | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user