Page 1 of 1

Entity System

Posted: Fri Apr 02, 2010 5:20 pm
by XianForce
So I'm trying to maintain a better coding style, and for the next game I plan to make, I want to make an 'EntitySystem'.

Now in my mind, I think of an Entity as anything that moves, so I was thinking of having the EntitySystem composed of 3 other systems:

*PlayableCharacterSystem
*NPCSystem
*(Placeholder) System - Not exactly sure what to call everything else that moves (such as bullets).

But my question is, is this a good set up? Should things such as bullets be grouped with Characters/NPCs?

(As an added note, I'm not making something huge like an RPG, just a SHMUP, but I want to be able to have a lot of reusable code in the end)

Thanks in advance for any input.

Re: Entity System

Posted: Fri Apr 02, 2010 5:55 pm
by GroundUpEngine
Heres my input, I use a vector of bullet objects in my player/character class and as long as it's a shooter I think it's perfectly fine ;)

Re: Entity System

Posted: Fri Apr 02, 2010 5:58 pm
by XianForce
GroundUpEngine wrote:Heres my input, I use a vector of bullet objects in my player/character class and as long as it's a shooter I think it's perfectly fine ;)
Hehe, makes sense...

It was just I thought of something that would be in my game last night right before I fell asleep, and then I thought about how to actually implement it, and how it moved and such... Then I woke up and forgot what it was... I just can't remember what it is, and where it would fit >.>

Re: Entity System

Posted: Fri Apr 02, 2010 6:22 pm
by GroundUpEngine
Cool. Hey ya think that's bad, I got all this crap that I wrote last night to try make sense of ;)

Code: Select all

class Entity;

Code: Select all

class Actor : public Entity;
class Object : public Entity;
class GUI : public Entity;
class Text : public Entity;

Code: Select all

class Player : public Actor;
class Enemy : public Actor;
// Player & Enemy has vector<Bullet>
class Vehicle : public Actor;
class Bullet : public Object; // hmm
class Item : public Object;
class Map; // Map has vector<Object*>
// e.g. Map->Object[i] = new Object;
class Console : public GUI;
class Textbox : public GUI;

Code: Select all

class Pushable : public Object;
// e.g. Map->Object[i] = new Pushable;

Re: Entity System

Posted: Fri Apr 02, 2010 6:32 pm
by XianForce
Haha... That's why I always draw some flow charts =D - They usually help explain crap like that to me >.>

Re: Entity System

Posted: Fri Apr 02, 2010 11:20 pm
by eatcomics
XianForce wrote:Haha... That's why I always draw some flow charts =D - They usually help explain crap like that to me >.>
Same, and if I come up with a solution at night, I can't sleep until I write it down...

Re: Entity System

Posted: Sat Apr 03, 2010 2:35 pm
by XianForce
eatcomics wrote:
XianForce wrote:Haha... That's why I always draw some flow charts =D - They usually help explain crap like that to me >.>
Same, and if I come up with a solution at night, I can't sleep until I write it down...
Unfortunately, my ideas come when I'm almost asleep - So I usually tell myself that I'll write it down in the morning, but then I forget >.>