Fixed Box class and some bugs in texture
This commit is contained in:
parent
1f3806b288
commit
d2fce2161e
9 changed files with 108 additions and 94 deletions
44
log.txt
44
log.txt
|
|
@ -1,18 +1,26 @@
|
|||
2007-04-12 15:05:12:500 # Loading texture: data/map/sand.jpg
|
||||
2007-04-12 15:05:13:015 # Loading texture: data/cursor/cursor.png
|
||||
2007-04-12 15:05:13:203 # Loading texture: data/units/tank.png
|
||||
2007-04-12 15:05:13:625 # Adding State: InGameState
|
||||
2007-04-12 15:05:13:625 # Loading texture: data/loadbar_front.png
|
||||
2007-04-12 15:05:13:734 # Loading texture: data/loadbar.png
|
||||
2007-04-12 15:05:13:750 # Loading texture: data/loadbar_back.png
|
||||
2007-04-12 15:05:13:765 # Adding State: LoadingState
|
||||
2007-04-12 15:05:13:781 # Loading texture: data/splash.png
|
||||
2007-04-12 15:05:14:531 # Adding State: SplashState
|
||||
2007-04-12 15:05:14:531 # Enabling(true) State: SplashState
|
||||
2007-04-12 15:05:20:968 # Removing State: SplashState
|
||||
2007-04-12 15:05:20:968 # Enabling(true) State: LoadingState
|
||||
2007-04-12 15:05:22:593 # Removing State: LoadingState
|
||||
2007-04-12 15:05:22:593 # Enabling(true) State: InGameState
|
||||
2007-04-12 15:05:24:562 # Moving: 2, 1
|
||||
2007-04-12 15:05:25:781 # Moving: 1, 1
|
||||
2007-04-12 15:05:26:234 # Moving: 4, 3
|
||||
2007-04-15 20:49:25:453 # Loading texture: data/map/sand.jpg
|
||||
2007-04-15 20:49:26:796 # Loading texture: data/cursor/cursor.png
|
||||
2007-04-15 20:49:27:203 # Loading texture: data/units/tank.png
|
||||
2007-04-15 20:49:27:671 # Adding State: InGameState
|
||||
2007-04-15 20:49:27:703 # Loading texture: data/loadbar_front.png
|
||||
2007-04-15 20:49:27:843 # Loading texture: data/loadbar.png
|
||||
2007-04-15 20:49:28:000 # Loading texture: data/loadbar_back.png
|
||||
2007-04-15 20:49:28:015 # Adding State: LoadingState
|
||||
2007-04-15 20:49:28:031 # Loading texture: data/splash.png
|
||||
2007-04-15 20:49:28:875 # Adding State: SplashState
|
||||
2007-04-15 20:49:28:875 # Enabling(true) State: SplashState
|
||||
2007-04-15 20:49:35:390 # Removing State: SplashState
|
||||
2007-04-15 20:49:35:390 # Enabling(true) State: LoadingState
|
||||
2007-04-15 20:49:37:000 # Removing State: LoadingState
|
||||
2007-04-15 20:49:37:000 # Enabling(true) State: InGameState
|
||||
2007-04-15 20:49:45:515 # Selecting: 0, 0
|
||||
2007-04-15 20:49:46:937 # Moving: 2, 2
|
||||
2007-04-15 20:49:50:000 # Moving: 6, 5
|
||||
2007-04-15 20:49:55:687 # Moving: 9, 4
|
||||
2007-04-15 20:50:02:328 # Moving: 10, 1
|
||||
2007-04-15 20:50:05:828 # Moving: 0, 0
|
||||
2007-04-15 20:50:13:218 # Moving: 1, 1
|
||||
2007-04-15 20:50:17:125 # Moving: 2, 2
|
||||
2007-04-15 20:50:18:968 # Moving: 3, 3
|
||||
2007-04-15 20:50:20:734 # Moving: 4, 4
|
||||
2007-04-15 20:50:23:453 # Moving: 0, 0
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ public class ProgressBar extends Entity{
|
|||
}
|
||||
if(progress != null){
|
||||
progress.setLocation(new Vector3f(
|
||||
(LWJGLGameWindow.getWidth()/2)-progress.getWidth(),
|
||||
(LWJGLGameWindow.getWidth()/2)-progress.getSize().getX(),
|
||||
(LWJGLGameWindow.getHeight()/2)+3,0.0f));
|
||||
}
|
||||
if(background != null){
|
||||
|
|
@ -199,7 +199,7 @@ public class ProgressBar extends Entity{
|
|||
if(background != null)background.render();
|
||||
if(progress != null){
|
||||
progress.setLocation(new Vector3f(
|
||||
getLocation().getX()-progress.getWidth()+(progress.getWidth()*procent),
|
||||
getLocation().getX()-progress.getSize().getX()+(progress.getSize().getX()*procent),
|
||||
getLocation().getY()+6,0.0f));
|
||||
progress.render();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,22 +4,25 @@ import java.awt.Rectangle;
|
|||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import ei.engine.math.Vector2f;
|
||||
import ei.engine.texture.Texture;
|
||||
import ei.engine.texture.TextureLoader;
|
||||
|
||||
public class LineBox extends Entity{
|
||||
public class Box extends Entity{
|
||||
/** The texture that stores the image for this sprite */
|
||||
private Texture texture;
|
||||
|
||||
/** The size of this entity */
|
||||
private Vector2f size;
|
||||
/**
|
||||
* Create a new empty sprite
|
||||
*
|
||||
* @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 LineBox(String name) {
|
||||
public Box(String name) {
|
||||
super(name);
|
||||
texture = new Texture();
|
||||
texture = new Texture();
|
||||
size = new Vector2f();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -28,9 +31,10 @@ public class LineBox extends Entity{
|
|||
* @param name The name of the sprite
|
||||
* @param texture The texture to use
|
||||
*/
|
||||
public LineBox(String name, Texture texture) {
|
||||
public Box(String name, Texture texture) {
|
||||
super(name);
|
||||
this.texture = texture;
|
||||
this.texture = texture;
|
||||
size = new Vector2f(texture.getImageWidth(),texture.getImageHeight());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -39,37 +43,33 @@ public class LineBox extends Entity{
|
|||
* @param name The name of the sprite
|
||||
* @param ref A reference to the image on which this sprite should be based
|
||||
*/
|
||||
public LineBox(String name, String ref) {
|
||||
public Box(String name, String ref) {
|
||||
super(name);
|
||||
this.texture = TextureLoader.getTextureLoaderInstance().getTexture(ref);
|
||||
size = new Vector2f(texture.getImageWidth(),texture.getImageHeight());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a vector2f with the size
|
||||
*
|
||||
* @return a vector2f with the size
|
||||
*/
|
||||
public Vector2f getSize(){
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the width of this sprite in pixels
|
||||
* Sets the size to the given values
|
||||
*
|
||||
* @return The width of this sprite in pixels
|
||||
* @param s A Vector2f with the size values
|
||||
*/
|
||||
public int getWidth() {
|
||||
if(texture == null){
|
||||
return 0;
|
||||
}
|
||||
return texture.getImageWidth();
|
||||
public void setSize(Vector2f s){
|
||||
size = s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the height of this sprite in pixels
|
||||
*
|
||||
* @return The height of this sprite in pixels
|
||||
*/
|
||||
public int getHeight() {
|
||||
if(texture == null){
|
||||
return 0;
|
||||
}
|
||||
return texture.getImageHeight();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the texture
|
||||
*
|
||||
* @return The texture
|
||||
*/
|
||||
public Texture getTexture(){
|
||||
|
|
@ -87,7 +87,7 @@ public class LineBox extends Entity{
|
|||
//Sets the location
|
||||
super.setTranslationGL();
|
||||
//the rotation
|
||||
super.setRotationGL(texture.getImageWidth()/2,texture.getImageHeight()/2);
|
||||
super.setRotationGL(size.getX()/2,size.getY()/2);
|
||||
//Sets the scale of the sprite
|
||||
super.setScaleGL();
|
||||
|
||||
|
|
@ -95,20 +95,20 @@ public class LineBox extends Entity{
|
|||
texture.bindGL();
|
||||
|
||||
// draw a quad textured to match the sprite
|
||||
GL11.glBegin(GL11.GL_LINES);
|
||||
GL11.glBegin(GL11.GL_LINE_LOOP);
|
||||
{
|
||||
//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());
|
||||
GL11.glVertex2f(0, size.getY());
|
||||
//Vertex at the upper right
|
||||
GL11.glTexCoord2f(texture.getWidth(), texture.getHeight());
|
||||
GL11.glVertex2f(texture.getImageWidth(),texture.getImageHeight());
|
||||
GL11.glVertex2f(size.getX(),size.getY());
|
||||
//Vertex at the down right
|
||||
GL11.glTexCoord2f(texture.getWidth(), 0);
|
||||
GL11.glVertex2f(texture.getImageWidth(),0);
|
||||
GL11.glVertex2f(size.getX(),0);
|
||||
}
|
||||
GL11.glEnd();
|
||||
|
||||
|
|
@ -76,7 +76,8 @@ public class Node extends Sprite {
|
|||
super.setScaleGL();
|
||||
|
||||
for(int i=0; i<entities.size() ;i++){
|
||||
entities.get(i).getTexture().setColor(getTexture().getColor());
|
||||
if(entities.get(i).getTexture() != null)
|
||||
entities.get(i).getTexture().getColor().setA(getTexture().getColor().getA());
|
||||
entities.get(i).render();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,7 +19,8 @@ import ei.engine.texture.TextureLoader;
|
|||
public class Sprite extends Entity {
|
||||
/** The texture that stores the image for this sprite */
|
||||
private Texture texture;
|
||||
|
||||
/** The size of this entity */
|
||||
private Vector2f size;
|
||||
/**
|
||||
* Create a new empty sprite
|
||||
*
|
||||
|
|
@ -27,7 +29,8 @@ public class Sprite extends Entity {
|
|||
*/
|
||||
public Sprite(String name) {
|
||||
super(name);
|
||||
texture = new Texture();
|
||||
texture = new Texture();
|
||||
size = new Vector2f();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -38,7 +41,8 @@ public class Sprite extends Entity {
|
|||
*/
|
||||
public Sprite(String name, Texture texture) {
|
||||
super(name);
|
||||
this.texture = texture;
|
||||
this.texture = texture;
|
||||
size = new Vector2f(texture.getImageWidth(),texture.getImageHeight());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -50,34 +54,31 @@ public class Sprite extends Entity {
|
|||
public Sprite(String name, String ref) {
|
||||
super(name);
|
||||
this.texture = TextureLoader.getTextureLoaderInstance().getTexture(ref);
|
||||
size = new Vector2f(texture.getImageWidth(),texture.getImageHeight());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a vector2f with the size
|
||||
*
|
||||
* @return a vector2f with the size
|
||||
*/
|
||||
public Vector2f getSize(){
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the width of this sprite in pixels
|
||||
* Sets the size to the given values
|
||||
*
|
||||
* @return The width of this sprite in pixels
|
||||
* @param s A Vector2f with the size values
|
||||
*/
|
||||
public int getWidth() {
|
||||
if(texture == null){
|
||||
return 0;
|
||||
}
|
||||
return texture.getImageWidth();
|
||||
public void setSize(Vector2f s){
|
||||
size = s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the height of this sprite in pixels
|
||||
*
|
||||
* @return The height of this sprite in pixels
|
||||
*/
|
||||
public int getHeight() {
|
||||
if(texture == null){
|
||||
return 0;
|
||||
}
|
||||
return texture.getImageHeight();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the texture
|
||||
*
|
||||
* @return The texture
|
||||
*/
|
||||
public Texture getTexture(){
|
||||
|
|
@ -95,7 +96,7 @@ public class Sprite extends Entity {
|
|||
//Sets the location
|
||||
super.setTranslationGL();
|
||||
//the rotation
|
||||
super.setRotationGL(texture.getImageWidth()/2,texture.getImageHeight()/2);
|
||||
super.setRotationGL(size.getX()/2,size.getY()/2);
|
||||
//Sets the scale of the sprite
|
||||
super.setScaleGL();
|
||||
|
||||
|
|
@ -110,13 +111,13 @@ public class Sprite extends Entity {
|
|||
GL11.glVertex2f(0, 0);
|
||||
//Vertex at the down left
|
||||
GL11.glTexCoord2f(0, texture.getHeight());
|
||||
GL11.glVertex2f(0, texture.getImageHeight());
|
||||
GL11.glVertex2f(0, size.getY());
|
||||
//Vertex at the upper right
|
||||
GL11.glTexCoord2f(texture.getWidth(), texture.getHeight());
|
||||
GL11.glVertex2f(texture.getImageWidth(),texture.getImageHeight());
|
||||
GL11.glVertex2f(size.getX(),size.getY());
|
||||
//Vertex at the down right
|
||||
GL11.glTexCoord2f(texture.getWidth(), 0);
|
||||
GL11.glVertex2f(texture.getImageWidth(),0);
|
||||
GL11.glVertex2f(size.getX(),0);
|
||||
}
|
||||
GL11.glEnd();
|
||||
|
||||
|
|
|
|||
|
|
@ -4,10 +4,13 @@ import ei.engine.LWJGLGameWindow;
|
|||
import ei.engine.effects.Particles;
|
||||
import ei.engine.math.Vector2f;
|
||||
import ei.engine.math.Vector3f;
|
||||
import ei.engine.math.Vector4f;
|
||||
import ei.engine.scene.Box;
|
||||
import ei.engine.scene.Node;
|
||||
import ei.engine.scene.Sprite;
|
||||
import ei.engine.sound.Sound;
|
||||
import ei.engine.state.GameState;
|
||||
import ei.engine.texture.Texture;
|
||||
|
||||
|
||||
public class GameStateTestState extends GameState{
|
||||
|
|
@ -22,9 +25,17 @@ public class GameStateTestState extends GameState{
|
|||
|
||||
sprite1 = new Sprite("tank","data/units/tank.png");
|
||||
//sprite1.setScale(new Vector2f(0.5f,0.5f));
|
||||
sprite1.setLocation(new Vector3f(0,0,0.2f));
|
||||
sprite1.setLocation(new Vector3f(400,300,0.2f));
|
||||
rootNode.add(sprite1);
|
||||
|
||||
Texture tex = new Texture();
|
||||
tex.setColor(new Vector4f(0.5f, 1.0f, 0.5f,1));
|
||||
Box box = new Box("box",tex);
|
||||
box.setLocation(sprite1.getLocation());
|
||||
box.setRotation(sprite1.getRotation());
|
||||
box.setSize(sprite1.getSize());
|
||||
rootNode.add(box);
|
||||
|
||||
p = new Particles("particle");
|
||||
p.setLocation(sprite1.getLocation().getCopy());
|
||||
p.getLocation().setZ(0.1f);
|
||||
|
|
@ -43,7 +54,7 @@ public class GameStateTestState extends GameState{
|
|||
|
||||
@Override
|
||||
public void update() {
|
||||
LWJGLGameWindow.getCamera().getLocation().add(new Vector2f(-1.5f,-1.5f));
|
||||
//LWJGLGameWindow.getCamera().getLocation().add(new Vector2f(-1.5f,-1.5f));
|
||||
sprite1.getRotation().add(0, 0, 0.5f);
|
||||
rootNode.update();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||
|
||||
import ei.engine.LWJGLGameWindow;
|
||||
import ei.engine.input.MouseInput;
|
||||
import ei.engine.math.Vector2f;
|
||||
import ei.engine.math.Vector2i;
|
||||
import ei.engine.scene.Sprite;
|
||||
import ei.engine.util.MultiPrintStream;
|
||||
|
|
@ -25,10 +26,7 @@ public class InGameMouseInput extends MouseInput{
|
|||
|
||||
//inits the mouse texture
|
||||
Sprite s = getSprite();
|
||||
s.getTexture().setTextureWidth(50);
|
||||
s.getTexture().setTextureHeight(50);
|
||||
s.getTexture().setWidth(50);
|
||||
s.getTexture().setHeight(50);
|
||||
s.setSize(new Vector2f(38,50));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -28,10 +28,7 @@ public class Map {
|
|||
for(int j=0; j<hight ;j++){
|
||||
Sprite s = new Sprite("MapPos("+i+","+j+")","data/map/sand.jpg");
|
||||
s.setLocation(new Vector3f(i*POS_SIZE,j*POS_SIZE,0));
|
||||
s.getTexture().setTextureWidth(POS_SIZE+1.2f);
|
||||
s.getTexture().setTextureHeight(POS_SIZE+1.2f);
|
||||
s.getTexture().setWidth(POS_SIZE);
|
||||
s.getTexture().setHeight(POS_SIZE);
|
||||
s.setSize(new Vector2f(POS_SIZE,POS_SIZE));
|
||||
mapNode.add(s);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package ei.game.scene.units;
|
||||
|
||||
import ei.engine.math.Vector2f;
|
||||
import ei.engine.scene.Sprite;
|
||||
|
||||
public class Tank extends Unit{
|
||||
|
|
@ -10,10 +11,7 @@ public class Tank extends Unit{
|
|||
public Tank(int x, int y){
|
||||
super(10);
|
||||
setSprite(new Sprite("Tank", "data/units/tank.png"));
|
||||
getSprite().getTexture().setTextureWidth(90);
|
||||
getSprite().getTexture().setTextureHeight(50);
|
||||
getSprite().getTexture().setWidth(90);
|
||||
getSprite().getTexture().setHeight(50);
|
||||
getSprite().setSize(new Vector2f(50,37));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue