diff --git a/src/ei/game/gamestate/InGameState.java b/src/ei/game/gamestate/InGameState.java index 29fd924..a5a8f48 100644 --- a/src/ei/game/gamestate/InGameState.java +++ b/src/ei/game/gamestate/InGameState.java @@ -15,12 +15,13 @@ public class InGameState extends GameState{ public InGameState(String name){ super(name); rootNode = new Node("InGameNode"); - InGameMouseInput mouse = new InGameMouseInput(); - super.getInput().addInput(mouse); - + map = new Map(20,20); rootNode.add(map.getMapNode()); + InGameMouseInput mouse = new InGameMouseInput(map); + super.getInput().addInput(mouse); + player = new Human(); rootNode.add(player.getNode()); } diff --git a/src/ei/game/input/InGameMouseInput.java b/src/ei/game/input/InGameMouseInput.java index 794e367..b2c18d0 100644 --- a/src/ei/game/input/InGameMouseInput.java +++ b/src/ei/game/input/InGameMouseInput.java @@ -45,7 +45,10 @@ public class InGameMouseInput extends MouseInput{ @Override public void mouseDown(int event,int x, int y) { - System.out.println("DOWN("+event+"): "+x+"-"+y); + System.out.println("DOWN("+event+"): "+x+"-"+y+map); + System.out.println(map.getPosByPixel( + LWJGLGameWindow.getCamera().getLocation().getX()+x, + LWJGLGameWindow.getCamera().getLocation().getY()+y)); } diff --git a/src/ei/game/player/Human.java b/src/ei/game/player/Human.java index 3f2c4df..785bc72 100644 --- a/src/ei/game/player/Human.java +++ b/src/ei/game/player/Human.java @@ -15,12 +15,16 @@ public class Human { unitsNode = new Node("UnitsNode"); } - public void addUnit(Unit u){ units.add(u); unitsNode.add(u.getSprite()); } + public void removeUnit(Unit u){ + units.remove(u); + unitsNode.remove(u.getSprite()); + } + public Node getNode(){ return unitsNode; } diff --git a/src/ei/game/scene/Map.java b/src/ei/game/scene/Map.java index 3ec4ca0..6b50943 100644 --- a/src/ei/game/scene/Map.java +++ b/src/ei/game/scene/Map.java @@ -1,5 +1,6 @@ package ei.game.scene; +import ei.engine.math.Vector2i; import ei.engine.math.Vector3f; import ei.engine.scene.Node; import ei.engine.scene.Sprite; @@ -35,6 +36,20 @@ public class Map { } } + public Vector2i getPosByPixel(float x, float y){ + System.out.println("DOWN: "+x+"-"+y); + x = x/POS_SIZE; + y = y/POS_SIZE; + System.out.println("DOWN: "+x+"-"+y); + return new Vector2i((int)x,(int)y); + } + + public Vector2i getPixelByPos(int x, int y){ + x = POS_SIZE*x; + y = POS_SIZE*y; + return new Vector2i((int)x,(int)y); + } + /** * Returns if the pos inthe map is empty *