LOLOOOOOOL

This commit is contained in:
Jesper Lundin 2007-04-04 16:28:57 +00:00
parent 69adb14553
commit 88d92f1b96
4 changed files with 62 additions and 7 deletions

View file

@ -4,6 +4,7 @@ import java.awt.Rectangle;
import org.lwjgl.opengl.GL11;
import ei.engine.math.Vector2f;
import ei.engine.texture.Texture;
import ei.engine.texture.TextureLoader;
@ -18,6 +19,7 @@ import ei.engine.texture.TextureLoader;
public class Sprite extends Entity {
/** The texture that stores the image for this sprite */
private Texture texture;
private Vector2f moveTo;
/**
* Create a new empty sprite
@ -75,7 +77,29 @@ public class Sprite extends Entity {
}
return texture.getImageHeight();
}
public void move(Vector2f vector) {
moveTo = vector;
}
public void update() {
if(moveTo!=null) {
if(moveTo.getX()>getLocation().getX()) {
getLocation().add(0.5f, 0f, 0f);
}
if(moveTo.getY()>getLocation().getY()) {
getLocation().add(0f, 0.5f, 0f);
}
if(moveTo.getX()<getLocation().getX()) {
getLocation().add(-0.5f, 0f, 0f);
}
if(moveTo.getY()<getLocation().getY()) {
getLocation().add(0f, -0.5f, 0f);
}
if(moveTo.getX()==getLocation().getX() && moveTo.getY()==getLocation().getY()) {
moveTo = null;
}
}
}
/**
* Returns the texture
* @return The texture