Jump to content
xisto Community
Sign in to follow this  
T X

Entity-based Games

Recommended Posts

Just a random thought.

public class Entity {		public Entity(String name, int type, int x, int y) {		setName(name).setType(type).setX(x).setY(y);	}		public String toString() {		return "[Entity - " + getName() + "]: Type: " + getType() + " X: " + getX() + " Y: " + getY() + ".";	}		public int getType() {		return type;	}		public int getX() {		return absX;	}		public int getY() {		return absY;	}		public String getName() {		return name;	}		public Entity setX(int x) {		this.absX = x;		return this;	}		public Entity setY(int y) {		this.absY = y;		return this;	}		public Entity setType(int type) {		this.type = type;		return this;	}		public Entity setName(String name) {		this.name = name;		return this;	}		private int type;	private int absX;	private int absY;	private String name;}
import java.util.List;import java.util.concurrent.CopyOnWriteArrayList;public class EntityManager {		public List<Entity> getEntities() {		return myEntities;	}		private List<Entity> myEntities = new CopyOnWriteArrayList<Entity>();}

public class EntityTest {		public EntityTest() {		getEntityManager().getEntities().add(player);		for(Entity e: getEntityManager().getEntities()) {			System.out.println(e.toString());		}	}		public static void main(String[] args) {		new EntityTest();	}		public EntityManager getEntityManager() {		return entityManager;	}		private EntityManager entityManager = new EntityManager();	private Entity player = new Entity("Player", 0, 0, 0);}

Tell me your thoughts! I just thought of this now so give me some credit ;).
Edited by T X (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.