From ec551064c4d7e77942f1bac5ef7feddd5b2225fe Mon Sep 17 00:00:00 2001 From: Ziver Koc Date: Mon, 26 Mar 2007 16:05:19 +0000 Subject: [PATCH] Added a AnimatedSprite for sequensed textures --- .project | 2 + log.txt | 7 +- src/ei/engine/scene/AnimatedSprite.java | 167 ++++++++++++++++++++++++ src/ei/engine/scene/Sprite.java | 4 + 4 files changed, 174 insertions(+), 6 deletions(-) create mode 100644 src/ei/engine/scene/AnimatedSprite.java diff --git a/.project b/.project index 24223ce..faf4826 100644 --- a/.project +++ b/.project @@ -12,6 +12,8 @@ + org.eclipse.jem.workbench.JavaEMFNature org.eclipse.jdt.core.javanature + org.eclipse.jem.beaninfo.BeanInfoNature diff --git a/log.txt b/log.txt index 8f13d32..edaaa6b 100644 --- a/log.txt +++ b/log.txt @@ -1,6 +1 @@ -2007-03-21 22:49:30:390 # Loading texture: data/units/tank.png -2007-03-21 22:49:31:187 # Loading texture: data/particle.bmp -2007-03-21 22:49:31:421 # Loading sound: data/sounds/test.wav -2007-03-21 22:49:31:437 # Sound sources: quantity=0 -2007-03-21 22:49:31:437 # Stoping sound: source=0 -2007-03-21 22:49:31:437 # Playing sound: source=0 buffer=261490744 +2007-03-26 16:59:28:234 # Loading texture: data/particle.bmp diff --git a/src/ei/engine/scene/AnimatedSprite.java b/src/ei/engine/scene/AnimatedSprite.java new file mode 100644 index 0000000..d995a46 --- /dev/null +++ b/src/ei/engine/scene/AnimatedSprite.java @@ -0,0 +1,167 @@ +package ei.engine.scene; + +import java.util.HashMap; + +import org.lwjgl.opengl.GL11; + +import ei.engine.texture.Texture; +import ei.engine.texture.TextureLoader; + +/** + * Implementation of sprite that uses an OpenGL quad and a texture + * to render a given image to the screen. + * + * @author Kevin Glass + * @author Brian Matzon + * @author Ziver Koc + */ +public class AnimatedSprite extends Entity { + /** The texture that stores the image for this sprite */ + private HashMap textures; + private String currentAnimation; + private int textureId; + + /** + * Create a new empty AnimatedSprite + * + * @param window The window in which the sprite will be displayed + * @param ref A reference to the image on which this sprite should be based + */ + public AnimatedSprite(String name) { + super(name); + textures = new HashMap(); + currentAnimation = null; + textureId = -1; + } + + /** + * Adds a vector of textures to the AnimationSprite + * + * @param name The name of the animation + * @param t The vector of textures + * @return true if successful else false + */ + public boolean addAnimation(String name, Texture[] t){ + if(!textures.containsKey(name)){ + textures.put(name,t); + return true; + } + return false; + } + + /** + * Adds a vector of textures to the AnimationSprite + * + * @param name The name of the animation + * @param t The path to the textures + * @return true if successful else false + */ + public boolean addAnimation(String name, String[] s){ + Texture[] t = new Texture[s.length]; + + for(int i=0; i= textureId){ + textureId = 0; + } + } + } +} \ No newline at end of file diff --git a/src/ei/engine/scene/Sprite.java b/src/ei/engine/scene/Sprite.java index 93529b1..8a9a09b 100644 --- a/src/ei/engine/scene/Sprite.java +++ b/src/ei/engine/scene/Sprite.java @@ -74,6 +74,10 @@ public class Sprite extends Entity { return texture.getImageHeight(); } + protected void bindTexture(){ + + } + /** * Draw the sprite */