• Create Account

### #ActualUssyless

Posted 18 February 2013 - 12:31 AM

Hi, so i'm wanting to work on a small personal project, involving me building my own simplish engine, and everything related, and at the moment, i'm creating entity types similar to this (this is the header file, not cpp)

class e_ship : public g_entity
{
public:
float x;
float y;
float xseepd;
float yseepd;
float dir;
float dirspeed;
g_texture spr;
public:

void midstep();
void draw();
void init();

};


and entities are spawned something like this

game->entities.push_back((new e_bullet));
what i'd like to have is a catalog of the entities in the game, perhaps something like this

g_entity classes[];
class classes[1] :public g_entity{};
- though this is redundant and wont work, i hope you see what i want to do, and i'd like to know how

the goal of this outcome would be to allow me to loop through the list, display any tags related to an entity (derivitive of X entity, solid, non solid etc), allow easy level editing , and just make the engine more robust, and also allow me to loop through and load all needed things for the entities used

my thoughts were as follows:

i would now need 2 entity identifiers, one to identify the class, and one to identify the unique entity once spawned
the class identifier would ideally be assigned automatically, however it would possibly be not realistic, or i might delete an entity i no longer need, then everything after it moves down one ID, and all entities in map/saves are subequently changed
and i would also need to know how exactly i would store these classes, some options i thought of would be

create the class like class e_ship : public g_entity

then pass the address to the library somehow

or
create them directly in the library somehow

- though i don't know what would work, or how i'd do it, i've tried some methods on my own that havent worked
i would need some way to actually catalogue these entities, would class classes[]; actually work?

thanks

### #3Ussyless

Posted 18 February 2013 - 12:25 AM

Hi, so i'm wanting to work on a small personal project, involving me building my own simplish engine, and everything related, and at the moment, i'm creating entity types similar to this (this is the header file, not cpp)

class e_ship : public g_entity
{
public:
float x;
float y;
float xseepd;
float yseepd;
float dir;
float dirspeed;
g_texture spr;
public:

void midstep();
void draw();
void init();

};


and entities are spawned something like this

game->entities.push_back((new e_bullet));
what i'd like to have is a catalog of the entities in the game, perhaps something like this

class classes[];
classes[1] :public g_entity{};

the goal of this outcome would be to allow me to loop through the list, display any tags related to an entity (derivitive of X entity, solid, non solid etc), allow easy level editing , and just make the engine more robust, and also allow me to loop through and load all needed things for the entities used

my thoughts were as follows:

i would now need 2 entity identifiers, one to identify the class, and one to identify the unique entity once spawned
the class identifier would ideally be assigned automatically, however it would possibly be not realistic, or i might delete an entity i no longer need, then everything after it moves down one ID, and all entities in map/saves are subequently changed

i would need some way to actually catalogue these entities, would class classes[]; actually work?

thanks

edit: i don't know why i said class classes[] when it should be g_entity classes[], which should work, i guess the correct question then is, how correct is this, are there any better ways of doing it?

### #2Ussyless

Posted 18 February 2013 - 12:23 AM

Hi, so i'm wanting to work on a small personal project, involving me building my own simplish engine, and everything related, and at the moment, i'm creating entity types similar to this (this is the header file, not cpp)

class e_ship : public g_entity
{
public:
float x;
float y;
float xseepd;
float yseepd;
float dir;
float dirspeed;
g_texture spr;
public:

void midstep();
void draw();
void init();

};


and entities are spawned something like this

game->entities.push_back((new e_bullet));
what i'd like to have is a catalog of the entities in the game, perhaps something like this

class classes[];
classes[1] :public g_entity{};

the goal of this outcome would be to allow me to loop through the list, display any tags related to an entity (derivitive of X entity, solid, non solid etc), allow easy level editing , and just make the engine more robust, and also allow me to loop through and load all needed things for the entities used

my thoughts were as follows:

i would now need 2 entity identifiers, one to identify the class, and one to identify the unique entity once spawned
the class identifier would ideally be assigned automatically, however it would possibly be not realistic, or i might delete an entity i no longer need, then everything after it moves down one ID, and all entities in map/saves are subequently changed

i would need some way to actually catalogue these entities, would class classes[]; actually work?

thanks

edit: i don't know why i said class classes[] when it should be g_entity classes[i], which should work, i guess the correct question then is, how correct is this, are there any better ways of doing it?

### #1Ussyless

Posted 18 February 2013 - 12:12 AM

Hi, so i'm wanting to work on a small personal project, involving me building my own simplish engine, and everything related, and at the moment, i'm creating entity types similar to this (this is the header file, not cpp)

class e_ship : public g_entity
{
public:
float x;
float y;
float xseepd;
float yseepd;
float dir;
float dirspeed;
g_texture spr;
public:

void midstep();
void draw();
void init();

};


and entities are spawned something like this

game->entities.push_back((new e_bullet));
what i'd like to have is a catalog of the entities in the game, perhaps something like this
class classes[];
classes[1] :public g_entity{};

the goal of this outcome would be to allow me to loop through the list, display any tags related to an entity (derivitive of X entity, solid, non solid etc), allow easy level editing , and just make the engine more robust, and also allow me to loop through and load all needed things for the entities used

my thoughts were as follows:

i would now need 2 entity identifiers, one to identify the class, and one to identify the unique entity once spawned
the class identifier would ideally be assigned automatically, however it would possibly be not realistic, or i might delete an entity i no longer need, then everything after it moves down one ID, and all entities in map/saves are subequently changed

i would need some way to actually catalogue these entities, would class classes[]; actually work?