diff --git a/src/ei/engine/effects/Particles.java b/src/ei/engine/effects/Particles.java index 313d2e5..57feefe 100644 --- a/src/ei/engine/effects/Particles.java +++ b/src/ei/engine/effects/Particles.java @@ -41,7 +41,9 @@ public class Particles extends Entity{ private static float colors[][][]= // Rainbow Of Colors { {{1.0f,0.5f,0.5f},{1.0f,1.0f,0.5f}}, - {{1.0f,1.0f,0.5f},{1.0f,0.5f,0.5f}} + {{1.0f,0.0f,0.5f},{0.0f,1.0f,0.5f}}, + {{0.0f,1.0f,0.5f},{0.0f,0.0f,1.0f}}, + {{1.0f,0.0f,1.0f},{1.0f,0.0f,0.0f}} }; private int maxParticles = 1000; diff --git a/src/ei/engine/input/MouseInput.java b/src/ei/engine/input/MouseInput.java index 543fb07..2d5ccc0 100644 --- a/src/ei/engine/input/MouseInput.java +++ b/src/ei/engine/input/MouseInput.java @@ -6,6 +6,8 @@ import org.lwjgl.opengl.GL11; import ei.engine.LWJGLGameWindow; import ei.engine.math.Vector2f; import ei.engine.math.Vector3f; +import ei.engine.scene.Entity; +import ei.engine.scene.Node; import ei.engine.scene.Sprite; /** @@ -23,12 +25,14 @@ public abstract class MouseInput extends Input{ private static int cursorY; // The texute for the mouse private Sprite cursor; + private Node mouseNode; public MouseInput(String name) { super(name); // init mouse: this will hide the native cursor (see drawCursor()) Mouse.setGrabbed(false); - + mouseNode = new Node("MouseInputNode"); + // set initial cursor pos to center screen cursorX = (int) LWJGLGameWindow.getWidth() / 2; cursorY = (int) LWJGLGameWindow.getHeight() / 2; @@ -39,6 +43,8 @@ public abstract class MouseInput extends Input{ // init mouse: this will hide the native cursor (see drawCursor()) Mouse.setGrabbed(true); cursor = new Sprite(name+" spatial",texture); + mouseNode = new Node("MouseInputNode"); + // set initial cursor pos to center screen cursorX = (int) LWJGLGameWindow.getWidth() / 2; cursorY = (int) LWJGLGameWindow.getHeight() / 2; @@ -52,11 +58,21 @@ public abstract class MouseInput extends Input{ public Sprite getSprite(){ return cursor; } + + /** + * Returns the sprite of th mouse + * + * @return The sprite of the mouse + */ + public Node getNode(){ + return mouseNode; + } /** * Renders the mous texture if texture set */ public void render() { + mouseNode.render(); if(cursor != null){ GL11.glPushMatrix(); Vector3f v = LWJGLGameWindow.getCamera().getLocation(); diff --git a/src/ei/game/EI.java b/src/ei/game/EI.java index bd5277b..ceabd12 100644 --- a/src/ei/game/EI.java +++ b/src/ei/game/EI.java @@ -7,7 +7,7 @@ import ei.game.gamestate.LoadingState; import ei.game.gamestate.SplashState; public class EI extends LWJGLGameWindow{ - public static final boolean debug = true; + public static final boolean debug = false; public static void main(String[] args){ new EI(); diff --git a/src/ei/game/input/InGameMouseInput.java b/src/ei/game/input/InGameMouseInput.java index f3f7a3d..9c46e4e 100644 --- a/src/ei/game/input/InGameMouseInput.java +++ b/src/ei/game/input/InGameMouseInput.java @@ -6,7 +6,10 @@ import ei.engine.LWJGLGameWindow; import ei.engine.input.MouseInput; import ei.engine.math.Vector2f; import ei.engine.math.Vector2i; +import ei.engine.math.Vector4f; +import ei.engine.scene.Box; import ei.engine.scene.Sprite; +import ei.engine.texture.Texture; import ei.engine.util.MultiPrintStream; import ei.game.scene.GameEntity; import ei.game.scene.Map; @@ -16,6 +19,8 @@ public class InGameMouseInput extends MouseInput{ private static final float CAMERA_MOVE_SPEED = 6.0f; private ArrayList selected; + private Vector2f leftKlickPos; + private Box markingBox; private Map map; @@ -27,6 +32,10 @@ public class InGameMouseInput extends MouseInput{ //inits the mouse texture Sprite s = getSprite(); s.setSize(new Vector2f(38,50)); + + Texture tex = new Texture(); + tex.setColor(new Vector4f(0.5f, 1.0f, 0.5f,1)); + markingBox = new Box("MarkingBob", tex); } @Override @@ -47,43 +56,83 @@ public class InGameMouseInput extends MouseInput{ if(y > LWJGLGameWindow.getHeight()-CAMERA_MOVE_BORDER){ LWJGLGameWindow.getCamera().getLocation().add(0,CAMERA_MOVE_SPEED,0); } + + // The + if(leftKlickPos != null){ + System.out.println("leftclick 2"); + markingBox.setSize(new Vector2f( + Math.abs(leftKlickPos.getX()-(LWJGLGameWindow.getCamera().getLocation().getX()+x)), + Math.abs(leftKlickPos.getY()-(LWJGLGameWindow.getCamera().getLocation().getY()+y)))); + getNode().add(markingBox); + } } @Override public void mouseDown(int event,int x, int y) { - System.out.println("DOWN("+event+"): "+x+"-"+y); Vector2i pos = Map.getPosByPixel( LWJGLGameWindow.getCamera().getLocation().getX()+x, LWJGLGameWindow.getCamera().getLocation().getY()+y); + //selecting unit. - if(event==RIGHT_MOUSE_BUTTON) { - for(int i=0; i