diff --git a/bin/data/units/tank.png b/bin/data/units/tank.png new file mode 100644 index 0000000..01b5a93 Binary files /dev/null and b/bin/data/units/tank.png differ diff --git a/bin/ei/engine/LWJGLGameWindow.class b/bin/ei/engine/LWJGLGameWindow.class new file mode 100644 index 0000000..ab17286 Binary files /dev/null and b/bin/ei/engine/LWJGLGameWindow.class differ diff --git a/bin/ei/engine/math/Vector2D.class b/bin/ei/engine/math/Vector2D.class new file mode 100644 index 0000000..0e61ff0 Binary files /dev/null and b/bin/ei/engine/math/Vector2D.class differ diff --git a/bin/ei/engine/math/Vector2I.class b/bin/ei/engine/math/Vector2I.class new file mode 100644 index 0000000..cba73dd Binary files /dev/null and b/bin/ei/engine/math/Vector2I.class differ diff --git a/bin/ei/engine/scene/Entity.class b/bin/ei/engine/scene/Entity.class new file mode 100644 index 0000000..0b1e283 Binary files /dev/null and b/bin/ei/engine/scene/Entity.class differ diff --git a/bin/ei/engine/scene/Node.class b/bin/ei/engine/scene/Node.class new file mode 100644 index 0000000..5b6af08 Binary files /dev/null and b/bin/ei/engine/scene/Node.class differ diff --git a/bin/ei/engine/scene/Sprite.class b/bin/ei/engine/scene/Sprite.class new file mode 100644 index 0000000..08765bc Binary files /dev/null and b/bin/ei/engine/scene/Sprite.class differ diff --git a/bin/ei/engine/state/GameState.class b/bin/ei/engine/state/GameState.class new file mode 100644 index 0000000..d013503 Binary files /dev/null and b/bin/ei/engine/state/GameState.class differ diff --git a/bin/ei/engine/state/GameStateManager.class b/bin/ei/engine/state/GameStateManager.class new file mode 100644 index 0000000..f677a6f Binary files /dev/null and b/bin/ei/engine/state/GameStateManager.class differ diff --git a/bin/ei/engine/util/Texture.class b/bin/ei/engine/util/Texture.class new file mode 100644 index 0000000..960fe3f Binary files /dev/null and b/bin/ei/engine/util/Texture.class differ diff --git a/bin/ei/engine/util/TextureLoader.class b/bin/ei/engine/util/TextureLoader.class new file mode 100644 index 0000000..b6d8344 Binary files /dev/null and b/bin/ei/engine/util/TextureLoader.class differ diff --git a/bin/ei/game/EI.class b/bin/ei/game/EI.class new file mode 100644 index 0000000..dd561a7 Binary files /dev/null and b/bin/ei/game/EI.class differ diff --git a/bin/ei/game/gamestate/InGameState.class b/bin/ei/game/gamestate/InGameState.class new file mode 100644 index 0000000..dce4943 Binary files /dev/null and b/bin/ei/game/gamestate/InGameState.class differ diff --git a/src/ei/engine/math/Vector2D.java b/src/ei/engine/math/Vector2D.java new file mode 100644 index 0000000..3bb50e8 --- /dev/null +++ b/src/ei/engine/math/Vector2D.java @@ -0,0 +1,42 @@ +package ei.engine.math; + +public class Vector2D { + private double x; + private double y; + + public Vector2D(double x, double y){ + this.x = x; + this.y = y; + } + + /** + * Get the X value + * + * @return the x value in the vector + */ + public double getX(){ + return x; + } + + /** + * Get the Y value + * + * @return the y value in the vector + */ + public double getY(){ + return y; + } + + /** + * Add to the vectro + * @param i The amount to add + */ + public void add(double i){ + x += i; + y += i; + } + + public String toString(){ + return "Vector2I["+x+","+y+"]"; + } +} diff --git a/src/ei/engine/scene/Entity.java b/src/ei/engine/scene/Entity.java new file mode 100644 index 0000000..6f9acfc --- /dev/null +++ b/src/ei/engine/scene/Entity.java @@ -0,0 +1,103 @@ +/** + * + */ +package ei.engine.scene; + +import ei.engine.math.Vector2D; +import ei.engine.math.Vector2I; + +/** + * This class is the root class of all the objects that + * will show on the scrren. This class handles the position + * and rotation and the colitions of the objects. + * @author Ziver + */ +public abstract class Entity { + /** The name of this sprite */ + private String name; + + /** The location of this entity in pixels*/ + private Vector2D location; + + /** The rotation of this entity in pixels*/ + private Vector2D rotation; + + /** The size of this entity in pixels*/ + private Vector2I size; + + /** + * creates a new entity + * + * @param name The name of the entity + */ + public Entity(String name){ + this.name = name; + location = new Vector2D(0,0); + } + + /** + * @return The name of the entity + */ + public String getName() { + return name; + } + + /** + * Get the Location of the entity + * + * @return The Location of the entity + */ + public Vector2D getLocation() { + return location; + } + + /** + * set the location of this entity in pixels + * + * @param l The location of the entity + */ + public void setLocation(Vector2D l) { + location = l; + } + + /** + * Get the rotation of the entity + * + * @return The Location of the entity + */ + public Vector2D getRotation() { + return rotation; + } + + /** + * set the rotation of this entity in pixels + * + * @param r The rotation of the entity + */ + public void setRotation(Vector2D r) { + rotation = r; + } + + /** + * Get the size of the entity + * + * @return The Location of the entity + */ + public Vector2I getSize() { + return size; + } + + /** + * set the size of this entity in pixels + * + * @param s The size of the entity + */ + public void setSize(Vector2I s) { + size = s; + } + + /** + * the render method shuold beimplemented for every entity + */ + public abstract void render(); +} diff --git a/src/ei/engine/scene/Sprite.java b/src/ei/engine/scene/Sprite.java index fa42fd5..325e5e3 100644 --- a/src/ei/engine/scene/Sprite.java +++ b/src/ei/engine/scene/Sprite.java @@ -4,7 +4,6 @@ import java.io.IOException; import org.lwjgl.opengl.GL11; -import ei.engine.math.Vector2I; import ei.engine.util.Texture; import ei.engine.util.TextureLoader; @@ -16,15 +15,9 @@ import ei.engine.util.TextureLoader; * @author Brian Matzon * @author Ziver Koc */ -public class Sprite { +public class Sprite extends Entity { /** The texture that stores the image for this sprite */ private Texture texture; - - /** The location of this sprite in pixels*/ - private Vector2I location; - - /** The name of this sprite */ - private String name; /** * Create a new empty sprite @@ -33,9 +26,8 @@ public class Sprite { * @param ref A reference to the image on which this sprite should be based */ public Sprite(String name) { - this.name = name; - texture = null; - location = new Vector2I(0,0); + super(name); + texture = null; } /** @@ -45,10 +37,9 @@ public class Sprite { * @param texture The texture to use */ public Sprite(String name, Texture texture) { - this.name = name; + super(name); this.texture = texture; - this.location = new Vector2I(texture.getImageWidth(),texture.getImageHeight()); -} + } /** * Create a new sprite from a specified image. @@ -57,11 +48,10 @@ public class Sprite { * @param ref A reference to the image on which this sprite should be based */ public Sprite(String name, String ref) { + super(name); try { - this.name = name; this.texture = TextureLoader.getTextureLoaderInstance().getTexture(ref); - - this.location = new Vector2I(texture.getImageWidth(),texture.getImageHeight()); + } catch (IOException e) { // a tad abrupt, but our purposes if you can't find a // sprite's image you might as well give up. @@ -94,41 +84,6 @@ public class Sprite { return texture.getImageHeight(); } - /** - * @return The name of this sprite - */ - public String getName() { - return name; - } - - /** - * Get the Location of the sprite - * - * @return The Location of the sprite - */ - public Vector2I getLocation() { - return location; - } - - /** - * set the location of this sprite in pixels - * - * @param x The x coordinate of the sprite - * @param y The y coordinate of the sprite - */ - public void setLocation(int x, int y) { - setLocation(new Vector2I(x,y)); - } - - /** - * set the location of this sprite in pixels - * - * @param v The location of the sprite - */ - public void setLocation(Vector2I v) { - location = v; - } - /** * Draw the sprite */ @@ -140,7 +95,7 @@ public class Sprite { texture.bind(); // translate to the right location and prepare to draw - GL11.glTranslatef(location.getX(), location.getY(), 0); + GL11.glTranslatef((int)getLocation().getX(), (int)getLocation().getY(), 0); GL11.glColor3f(1,1,1); // draw a quad textured to match the sprite diff --git a/src/ei/game/gamestate/InGameState.java b/src/ei/game/gamestate/InGameState.java index d50062d..53b7f3c 100644 --- a/src/ei/game/gamestate/InGameState.java +++ b/src/ei/game/gamestate/InGameState.java @@ -14,7 +14,6 @@ public class InGameState extends GameState{ rootNode = new Node("InGameNode"); s1 = new Sprite("tank","data/units/tank.png"); rootNode.add(s1); - s1.setLocation(1, 1); } @Override @@ -24,7 +23,7 @@ public class InGameState extends GameState{ @Override public void update() { - s1.getLocation().add(1); + s1.getLocation().add(0.1); } }