Added ability to move units
This commit is contained in:
parent
7c5cbe83fa
commit
ef64874f36
3 changed files with 19 additions and 13 deletions
|
|
@ -2,7 +2,6 @@ package ei.engine.test;
|
||||||
|
|
||||||
import ei.engine.LWJGLGameWindow;
|
import ei.engine.LWJGLGameWindow;
|
||||||
import ei.engine.effects.BitmapText;
|
import ei.engine.effects.BitmapText;
|
||||||
import ei.engine.effects.Text;
|
|
||||||
import ei.engine.math.Vector2f;
|
import ei.engine.math.Vector2f;
|
||||||
|
|
||||||
public class TextTest extends LWJGLGameWindow{
|
public class TextTest extends LWJGLGameWindow{
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@ import ei.engine.LWJGLGameWindow;
|
||||||
import ei.engine.input.MouseInput;
|
import ei.engine.input.MouseInput;
|
||||||
import ei.engine.math.Vector2i;
|
import ei.engine.math.Vector2i;
|
||||||
import ei.engine.scene.Sprite;
|
import ei.engine.scene.Sprite;
|
||||||
|
import ei.engine.util.MultiPrintStream;
|
||||||
import ei.game.scene.GameEntity;
|
import ei.game.scene.GameEntity;
|
||||||
import ei.game.scene.Map;
|
import ei.game.scene.Map;
|
||||||
import ei.game.scene.units.Unit;
|
|
||||||
|
|
||||||
public class InGameMouseInput extends MouseInput{
|
public class InGameMouseInput extends MouseInput{
|
||||||
private static final int CAMERA_MOVE_BORDER = 40;
|
private static final int CAMERA_MOVE_BORDER = 40;
|
||||||
|
|
@ -49,7 +49,6 @@ public class InGameMouseInput extends MouseInput{
|
||||||
if(y > LWJGLGameWindow.getHeight()-CAMERA_MOVE_BORDER){
|
if(y > LWJGLGameWindow.getHeight()-CAMERA_MOVE_BORDER){
|
||||||
LWJGLGameWindow.getCamera().getLocation().add(0,-CAMERA_MOVE_SPEED,0);
|
LWJGLGameWindow.getCamera().getLocation().add(0,-CAMERA_MOVE_SPEED,0);
|
||||||
}
|
}
|
||||||
//System.out.println(x+"-"+y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -59,14 +58,15 @@ public class InGameMouseInput extends MouseInput{
|
||||||
LWJGLGameWindow.getCamera().getLocation().getX()+x,
|
LWJGLGameWindow.getCamera().getLocation().getX()+x,
|
||||||
LWJGLGameWindow.getCamera().getLocation().getY()+(LWJGLGameWindow.getHeight()-y));
|
LWJGLGameWindow.getCamera().getLocation().getY()+(LWJGLGameWindow.getHeight()-y));
|
||||||
if(!map.isPosEmpty(pos.getX(), pos.getY())){
|
if(!map.isPosEmpty(pos.getX(), pos.getY())){
|
||||||
|
//map.printAllUnits();
|
||||||
selected.clear();
|
selected.clear();
|
||||||
System.out.println(pos.getX()+", "+pos.getY());
|
MultiPrintStream.out.println("Selecting: "+pos.getX()+", "+pos.getY());
|
||||||
selected.add(map.getPos(pos.getX(), pos.getY()));
|
selected.add(map.getPos(pos.getX(), pos.getY()));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
MultiPrintStream.out.println("Moving: "+pos.getX()+", "+pos.getY());
|
||||||
for(int i=0; i<selected.size() ;i++){
|
for(int i=0; i<selected.size() ;i++){
|
||||||
selected.get(i).move(pos.getX(),pos.getY());
|
selected.get(i).move(pos.getX(),pos.getY());
|
||||||
System.out.println("Lolz");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,16 +69,9 @@ public class Map {
|
||||||
* @return True if empty else false
|
* @return True if empty else false
|
||||||
*/
|
*/
|
||||||
public boolean isPosEmpty(int x, int y){
|
public boolean isPosEmpty(int x, int y){
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -122,4 +115,18 @@ public class Map {
|
||||||
public Node getMapNode(){
|
public Node getMapNode(){
|
||||||
return mapNode;
|
return mapNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints all the units on the map
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void printAllUnits(){
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue