This commit is contained in:
Ziver Koc 2007-04-04 16:00:09 +00:00
parent e9db4c48e3
commit 257d7e9db5
4 changed files with 28 additions and 5 deletions

View file

@ -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());
}

View file

@ -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));
}

View file

@ -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;
}

View file

@ -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
*