Fixed problem with select

This commit is contained in:
Ziver Koc 2007-04-18 12:19:54 +00:00
parent 95053aa6b5
commit 98c7550e83

View file

@ -59,7 +59,6 @@ public class InGameMouseInput extends MouseInput{
// The // The
if(leftKlickPos != null){ if(leftKlickPos != null){
System.out.println("leftclick 2");
markingBox.setSize(new Vector2f( markingBox.setSize(new Vector2f(
Math.abs(leftKlickPos.getX()-(LWJGLGameWindow.getCamera().getLocation().getX()+x)), Math.abs(leftKlickPos.getX()-(LWJGLGameWindow.getCamera().getLocation().getX()+x)),
Math.abs(leftKlickPos.getY()-(LWJGLGameWindow.getCamera().getLocation().getY()+y)))); Math.abs(leftKlickPos.getY()-(LWJGLGameWindow.getCamera().getLocation().getY()+y))));
@ -77,7 +76,6 @@ public class InGameMouseInput extends MouseInput{
if(event==LEFT_MOUSE_BUTTON){ if(event==LEFT_MOUSE_BUTTON){
//map.printAllUnits(); //map.printAllUnits();
if(leftKlickPos == null){ if(leftKlickPos == null){
System.out.println("leftclick 1");
leftKlickPos = new Vector2f(x,y); leftKlickPos = new Vector2f(x,y);
markingBox.setLocation(leftKlickPos); markingBox.setLocation(leftKlickPos);
} }
@ -113,15 +111,16 @@ public class InGameMouseInput extends MouseInput{
} }
public void selectUnits(Vector2i startPos, Vector2i stopPos){ public void selectUnits(Vector2i startPos, Vector2i stopPos){
MultiPrintStream.out.println("Selecting: "+startPos.getX()+", "+startPos.getY()+" to "+stopPos.getX()+", "+stopPos.getY());
for(int i=Math.min(startPos.getX(), stopPos.getX()); i<Math.max(startPos.getX(), stopPos.getX()) ;i++){ for(int i=Math.min(startPos.getX(), stopPos.getX()); i<=Math.max(startPos.getX(), stopPos.getX()) ;i++){
for(int j=Math.min(startPos.getY(), stopPos.getY()); j<Math.max(startPos.getY(), stopPos.getY()) ;j++){ for(int j=Math.min(startPos.getY(), stopPos.getY()); j<=Math.max(startPos.getY(), stopPos.getY()) ;j++){
if(!map.isPosEmpty(i, j)){ if(!map.isPosEmpty(i, j)){
selected.add(map.getPos(i, j)); selected.add(map.getPos(i, j));
map.getPos(i, j).setSelected(true); map.getPos(i, j).setSelected(true);
} }
} }
} }
} }
/** /**