Added a player handler so the code look a bit better
This commit is contained in:
parent
34decd72e4
commit
c2a579788a
6 changed files with 167 additions and 15 deletions
|
|
@ -3,7 +3,8 @@ package ei.game.gamestate;
|
|||
import ei.engine.scene.Node;
|
||||
import ei.engine.state.GameState;
|
||||
import ei.game.input.InGameMouseInput;
|
||||
import ei.game.player.Human;
|
||||
import ei.game.player.HumanPlayer;
|
||||
import ei.game.player.PlayerHandler;
|
||||
import ei.game.scene.Map;
|
||||
import ei.game.scene.units.Tank;
|
||||
|
||||
|
|
@ -11,7 +12,6 @@ import ei.game.scene.units.Tank;
|
|||
public class InGameState extends GameState{
|
||||
private Node rootNode;
|
||||
private static Map map;
|
||||
private static Human player;
|
||||
|
||||
public InGameState(String name){
|
||||
super(name);
|
||||
|
|
@ -22,24 +22,32 @@ public class InGameState extends GameState{
|
|||
InGameMouseInput mouse = new InGameMouseInput(map);
|
||||
super.getInput().addInput(mouse);
|
||||
|
||||
|
||||
player = new Human();
|
||||
HumanPlayer player = new HumanPlayer();
|
||||
player.addUnit(new Tank());
|
||||
rootNode.add(player.getNode());
|
||||
Tank tank = new Tank();
|
||||
player.addUnit(tank);
|
||||
//tank.move(10, 3);
|
||||
}
|
||||
public static Human getHuman(){
|
||||
return player;
|
||||
PlayerHandler.getInstance().addPlayer(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the gamestate
|
||||
*/
|
||||
public void render() {
|
||||
rootNode.render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the gamestate
|
||||
*/
|
||||
public void update() {
|
||||
PlayerHandler.getInstance().update();
|
||||
rootNode.update();
|
||||
}
|
||||
|
||||
/**
|
||||
*Returns the map of the game
|
||||
*
|
||||
* @return The map of the game
|
||||
*/
|
||||
public static Map getMap() {
|
||||
return map;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue