evil-inside/src/ei/game/gamestate/InGameState.java

57 lines
1.2 KiB
Java

package ei.game.gamestate;
import ei.engine.scene.Node;
import ei.engine.state.GameState;
import ei.game.input.InGameMouseInput;
import ei.game.player.HumanPlayer;
import ei.game.player.PlayerHandler;
import ei.game.scene.Map;
import ei.game.scene.units.Tank;
public class InGameState extends GameState{
private Node rootNode;
private static Map map;
public InGameState(String name){
super(name);
rootNode = new Node("InGameNode");
map = new Map(20,20);
rootNode.add(map.getMapNode());
InGameMouseInput mouse = new InGameMouseInput(map);
super.getInput().addInput(mouse);
HumanPlayer player = new HumanPlayer();
player.addUnit(new Tank());
player.addUnit(new Tank(1,0));
player.addUnit(new Tank(2,0));
rootNode.add(player.getNode());
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;
}
}