This commit is contained in:
Ziver Koc 2007-04-18 12:02:58 +00:00
parent 02316b71b3
commit a8f465ac6b
4 changed files with 92 additions and 25 deletions

View file

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