Fixed mouse coordinates

This commit is contained in:
Ziver Koc 2007-04-04 18:13:38 +00:00
parent 71011aa33a
commit e19132c65f
2 changed files with 11 additions and 5 deletions

View file

@ -54,10 +54,10 @@ public class InGameMouseInput extends MouseInput{
@Override @Override
public void mouseDown(int event,int x, int y) { public void mouseDown(int event,int x, int y) {
System.out.println("DOWN("+event+"): "+x+"-"+y+map); System.out.println("DOWN("+event+"): "+x+"-"+y);
Vector2i pos = map.getPosByPixel( Vector2i pos = map.getPosByPixel(
LWJGLGameWindow.getCamera().getLocation().getX()+x, LWJGLGameWindow.getCamera().getLocation().getX()+x,
LWJGLGameWindow.getCamera().getLocation().getY()+y); LWJGLGameWindow.getCamera().getLocation().getY()+(LWJGLGameWindow.getHeight()-y));
if(!map.isPosEmpty(pos.getX(), pos.getY())){ if(!map.isPosEmpty(pos.getX(), pos.getY())){
selected.clear(); selected.clear();
System.out.println(pos.getX()+", "+pos.getY()); System.out.println(pos.getX()+", "+pos.getY());
@ -65,8 +65,8 @@ public class InGameMouseInput extends MouseInput{
} }
else{ else{
for(int i=0; i<selected.size() ;i++){ for(int i=0; i<selected.size() ;i++){
Unit u = (Unit) selected.get(i); selected.get(i).move(pos.getX(),pos.getY());
u.move(pos.getX(),pos.getY()); System.out.println("Lolz");
} }
} }
} }
@ -74,7 +74,6 @@ public class InGameMouseInput extends MouseInput{
@Override @Override
public void mouseUp(int event,int x, int y) { public void mouseUp(int event,int x, int y) {
System.out.println("UP("+event+"): "+x+"-"+y); System.out.println("UP("+event+"): "+x+"-"+y);
} }
} }

View file

@ -72,6 +72,13 @@ public class Map {
if(map[x][y] != null){ if(map[x][y] != null){
return true; return true;
} }
for(int i=0; i<width ;i++){
for(int j=0; j<hight ;j++){
if(map[i][j] != null){
System.out.println("LOL: "+i+" "+j);
}
}
}
return false; return false;
} }