changed Vector2D to Vector2f insted and added sound but the sound is not finnishd yet.

and added a update method to entity for ex the sound entity to update its position in the 
world. Added loging support to whit MultiPrintStream.java
This commit is contained in:
Ziver Koc 2007-03-15 19:52:28 +00:00
parent b2cf5d543b
commit 9d4810d38e
37 changed files with 1262 additions and 39 deletions

View file

@ -3,8 +3,7 @@
*/
package ei.engine.scene;
import ei.engine.math.Vector2D;
import ei.engine.math.Vector2I;
import ei.engine.math.Vector2f;
/**
* This class is the root class of all the objects that
@ -17,13 +16,13 @@ public abstract class Entity {
private String name;
/** The location of this entity in pixels*/
private Vector2D location;
private Vector2f location;
/** The rotation of this entity in pixels*/
private Vector2D rotation;
private Vector2f rotation;
/** The size of this entity in pixels*/
private Vector2I size;
private Vector2f size;
/**
* creates a new entity
@ -32,7 +31,7 @@ public abstract class Entity {
*/
public Entity(String name){
this.name = name;
location = new Vector2D(0,0);
location = new Vector2f(0,0);
}
/**
@ -47,7 +46,7 @@ public abstract class Entity {
*
* @return The Location of the entity
*/
public Vector2D getLocation() {
public Vector2f getLocation() {
return location;
}
@ -56,7 +55,7 @@ public abstract class Entity {
*
* @param l The location of the entity
*/
public void setLocation(Vector2D l) {
public void setLocation(Vector2f l) {
location = l;
}
@ -65,7 +64,7 @@ public abstract class Entity {
*
* @return The Location of the entity
*/
public Vector2D getRotation() {
public Vector2f getRotation() {
return rotation;
}
@ -74,7 +73,7 @@ public abstract class Entity {
*
* @param r The rotation of the entity
*/
public void setRotation(Vector2D r) {
public void setRotation(Vector2f r) {
rotation = r;
}
@ -83,7 +82,7 @@ public abstract class Entity {
*
* @return The Location of the entity
*/
public Vector2I getSize() {
public Vector2f getSize() {
return size;
}
@ -92,12 +91,17 @@ public abstract class Entity {
*
* @param s The size of the entity
*/
public void setSize(Vector2I s) {
public void setSize(Vector2f s) {
size = s;
}
/**
* the render method shuold beimplemented for every entity
* the render method should be implemented for every entity
*/
public abstract void render();
/**
* the update method can be implemented for every entity
*/
public void update(){}
}

View file

@ -4,70 +4,79 @@ import java.util.ArrayList;
public class Node extends Sprite {
/** the sprites of this node */
protected ArrayList<Sprite> sprites;
protected ArrayList<Entity> entities;
public Node(String name) {
super(name);
sprites = new ArrayList<Sprite>();
entities = new ArrayList<Entity>();
}
/**
* Add a Sprite
* Add a Entity
* @param s the Sprite to add
* @return false if the Sprite alredy exist else true
* @return false if the Entity alredy exist else true
*/
public boolean add(Sprite s){
if(!sprites.contains(s)){
sprites.add(s);
public boolean add(Entity s){
if(!entities.contains(s)){
entities.add(s);
return true;
}
return false;
}
/**
* get a Sprite
* @param name the name of Sprite to get
* @return null if the Sprite wasnt found
* get a Entity
* @param name the name of Entity to get
* @return null if the Entity wasnt found
*/
public Sprite get(String name){
public Entity get(String name){
int i = getId(name);
if(i >= 0){
return sprites.get(i);
return entities.get(i);
}
return null;
}
/**
* remove a Sprite
* @param name the name of Sprite to remove
* @return false if the Sprite alredy exist else true
* remove a Entity
* @param name the name of Entity to remove
* @return false if the Entity alredy exist else true
*/
public boolean remove(String name){
int i = getId(name);
if(i >= 0){
sprites.remove(i);
entities.remove(i);
return true;
}
return false;
}
/**
* Draw all the sprites in the node
* Draw all the Entities in the node
*/
public void render() {
for(int i=0; i<sprites.size() ;i++){
sprites.get(i).render();
for(int i=0; i<entities.size() ;i++){
entities.get(i).render();
}
}
/**
* Searches for the given name of a sprite
* @param name The name of the sprite
* @return The index of the sprite
* update all the Entities in the node
*/
public void update() {
for(int i=0; i<entities.size() ;i++){
entities.get(i).update();
}
}
/**
* Searches for the given name of a Entity
* @param name The name of the Entity
* @return The index of the Entity
*/
private int getId(String name){
for(int i=0; i<sprites.size() ;i++){
if(sprites.get(i).getName().equals(name)){
for(int i=0; i<entities.size() ;i++){
if(entities.get(i).getName().equals(name)){
return i;
}
}

View file

@ -4,8 +4,8 @@ import java.io.IOException;
import org.lwjgl.opengl.GL11;
import ei.engine.util.Texture;
import ei.engine.util.TextureLoader;
import ei.engine.texture.Texture;
import ei.engine.texture.TextureLoader;
/**
* Implementation of sprite that uses an OpenGL quad and a texture