Added rotation capability and added a new calss Vector3f that holds 3 float values for ex rotation

This commit is contained in:
Ziver Koc 2007-03-17 16:29:39 +00:00
parent c0c78e74dc
commit dd696b2760
9 changed files with 208 additions and 17 deletions

View file

@ -83,35 +83,47 @@ public class Sprite extends Entity {
}
return texture.getImageHeight();
}
/**
* Draw the sprite
*/
public void render() {
// store the current model matrix
GL11.glPushMatrix();
//Reset The Current Modelview Matrix
GL11.glLoadIdentity();
//set rotation of the sprite
// And the rotation
setRotationGL();
//Set the location
setTranslationGL();
// bind to the appropriate texture for this sprite
texture.bind();
// translate to the right location and prepare to draw
GL11.glTranslatef((int)getLocation().getX(), (int)getLocation().getY(), 0);
texture.bindGL();
GL11.glColor3f(1,1,1);
// draw a quad textured to match the sprite
GL11.glBegin(GL11.GL_QUADS);
{
//Vertex at the upper left
GL11.glTexCoord2f(0, 0);
GL11.glVertex2f(0, 0);
//Vertex at the down left
GL11.glTexCoord2f(0, texture.getHeight());
GL11.glVertex2f(0, texture.getImageHeight());
//Vertex at the upper right
GL11.glTexCoord2f(texture.getWidth(), texture.getHeight());
GL11.glVertex2f(texture.getImageWidth(),texture.getImageHeight());
//Vertex at the down right
GL11.glTexCoord2f(texture.getWidth(), 0);
GL11.glVertex2f(texture.getImageWidth(),0);
}
GL11.glEnd();
//Reset The Current Modelview Matrix
GL11.glLoadIdentity();
// restore the model view matrix to prevent contamination
GL11.glPopMatrix();
}