diff --git a/log.txt b/log.txt index 3369f7b..66d55ff 100644 --- a/log.txt +++ b/log.txt @@ -1,4 +1,4 @@ -2007-03-17 17:23:35:625 # Loading sound: data/sounds/test.wav -2007-03-17 17:23:35:656 # Sound sources: quantity=0 -2007-03-17 17:23:35:656 # Stoping sound: source=0 -2007-03-17 17:23:35:656 # Playing sound: source=0 buffer=264767544 +2007-03-18 18:37:49:515 # Loading sound: data/sounds/test.wav +2007-03-18 18:37:49:531 # Sound sources: quantity=0 +2007-03-18 18:37:49:531 # Stoping sound: source=0 +2007-03-18 18:37:49:531 # Playing sound: source=0 buffer=264767544 diff --git a/src/ei/engine/LWJGLGameWindow.java b/src/ei/engine/LWJGLGameWindow.java index 400d5d3..e01e3ca 100644 --- a/src/ei/engine/LWJGLGameWindow.java +++ b/src/ei/engine/LWJGLGameWindow.java @@ -129,10 +129,12 @@ public class LWJGLGameWindow { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); - + + GL11.glPushMatrix(); //let subsystem paint GameStateManager.getInstance().render(); render(); + GL11.glPopMatrix(); //update window contents Display.update(); diff --git a/src/ei/engine/scene/Entity.java b/src/ei/engine/scene/Entity.java index 6167aa7..072912b 100644 --- a/src/ei/engine/scene/Entity.java +++ b/src/ei/engine/scene/Entity.java @@ -36,7 +36,7 @@ public abstract class Entity { this.name = name; location = new Vector2f(); rotation = new Vector3f(); - size = new Vector2f(); + size = new Vector2f(1,1); } /** @@ -83,20 +83,20 @@ public abstract class Entity { } /** - * Get the size of the entity + * Get the scale of the entity * * @return The Location of the entity */ - public Vector2f getSize() { + public Vector2f getScale() { return size; } /** - * set the size of this entity in pixels + * set the scale of this entity in pixels * * @param s The size of the entity */ - public void setSize(Vector2f s) { + public void setScale(Vector2f s) { size = s; } @@ -110,15 +110,19 @@ public abstract class Entity { } /** - * Sets the location of the entity in opengl plus - * the parameter values before rendering. + * Sets the location of the entity in opengl * * @param x The value to add x * @param y The value to add y */ protected void setTranslationGL(float x, float y){ // translate to the right location and prepare to draw - GL11.glTranslatef(location.getX()+x, location.getY()+y, 0); + GL11.glTranslatef(x,y, 0); + } + + protected void setScaleGL(){ + // translate to the right location and prepare to draw + GL11.glScalef(size.getX(), size.getY(), 0.0f); } /** diff --git a/src/ei/engine/scene/Sprite.java b/src/ei/engine/scene/Sprite.java index 51bcee0..732b289 100644 --- a/src/ei/engine/scene/Sprite.java +++ b/src/ei/engine/scene/Sprite.java @@ -92,13 +92,16 @@ public class Sprite extends Entity { GL11.glPushMatrix(); //Reset The Current Modelview Matrix GL11.glLoadIdentity(); + + //Sets the scale of the sprite + super.setScaleGL(); + //Sets the location + super.setTranslationGL(); + //the rotation + super.setRotationGL(); + //and sets back the rotation so that the rotation pivot is the center of the sprite + super.setTranslationGL(-texture.getImageWidth()/2,-texture.getImageHeight()/2); - //set rotation of the sprite - // And the rotation - setRotationGL(); - //Set the location - setTranslationGL(); - // bind to the appropriate texture for this sprite texture.bindGL(); GL11.glColor3f(1,1,1); diff --git a/src/ei/game/gamestate/InGameState.java b/src/ei/game/gamestate/InGameState.java index 4e84513..9b17232 100644 --- a/src/ei/game/gamestate/InGameState.java +++ b/src/ei/game/gamestate/InGameState.java @@ -15,10 +15,13 @@ public class InGameState extends GameState{ public InGameState(String name){ super(name); rootNode = new Node("InGameNode"); + sprite1 = new Sprite("tank","data/units/tank.png"); + sprite1.setScale(new Vector2f(0.5f,0.5f)); rootNode.add(sprite1); + sound1 = new Sound("sound","data/sounds/test.wav"); - sound1.play(); + sound1.loop(); rootNode.add(sound1); } @@ -29,7 +32,7 @@ public class InGameState extends GameState{ @Override public void update() { - sprite1.getLocation().add(0.1f); + sprite1.getLocation().add(0.5f); sprite1.getRotation().add(0, 0, 0.5f); sound1.getLocation().add(new Vector2f(1,0)); rootNode.update();