WIP GameLib_RemoveEntity
This commit is contained in:
@@ -11,9 +11,9 @@
|
|||||||
////////////////////////////////////////////////
|
////////////////////////////////////////////////
|
||||||
// Entity
|
// Entity
|
||||||
//
|
//
|
||||||
#define EntityFlag_Collision 1
|
#define EntityFlag_Collision 0x00000001
|
||||||
#define EntityFlag_Overlap 2
|
#define EntityFlag_Overlap 0x00000002
|
||||||
#define EntityFlag_Light 4
|
#define EntityFlag_Light 0x00000004
|
||||||
#define EntityFlag_BlockTop 0x00000100
|
#define EntityFlag_BlockTop 0x00000100
|
||||||
#define EntityFlag_BlockRight 0x00000200
|
#define EntityFlag_BlockRight 0x00000200
|
||||||
#define EntityFlag_BlockBottom 0x00000400
|
#define EntityFlag_BlockBottom 0x00000400
|
||||||
|
|||||||
@@ -121,6 +121,13 @@ void GameLib_CheckSize() {
|
|||||||
//
|
//
|
||||||
// Adds an entity to the game.
|
// Adds an entity to the game.
|
||||||
void GameLib_AddEntity(Entity e) {
|
void GameLib_AddEntity(Entity e) {
|
||||||
|
// Avoid duplications
|
||||||
|
for (int i = 0; i < g_NumEntities; i++) {
|
||||||
|
if (g_Entity[i] == e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (g_NumEntities >= g_NumEntitiesAllocated) {
|
if (g_NumEntities >= g_NumEntitiesAllocated) {
|
||||||
Entity *entity_aux;
|
Entity *entity_aux;
|
||||||
int *entity_flag_aux;
|
int *entity_flag_aux;
|
||||||
@@ -162,6 +169,23 @@ void GameLib_AddEntity(Entity e) {
|
|||||||
Entity_Init(e);
|
Entity_Init(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////////////////////////////
|
||||||
|
// GameLib_RemoveEntity
|
||||||
|
//
|
||||||
|
// removes the entity.
|
||||||
|
int GameLib_RemoveEntity(Entity e) {
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < g_NumEntities; i++) {
|
||||||
|
if (e == g_Entity[i]) {
|
||||||
|
// Mark to forget
|
||||||
|
g_EntityFlag[i] = -2;
|
||||||
|
g_EntitiesCompactate = 1;
|
||||||
|
return (i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
// GameLib_UnrefEntity
|
// GameLib_UnrefEntity
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -35,6 +35,12 @@ void GameLib_CheckSize();
|
|||||||
// Adds an entity to the game.
|
// Adds an entity to the game.
|
||||||
void GameLib_AddEntity(Entity e);
|
void GameLib_AddEntity(Entity e);
|
||||||
|
|
||||||
|
/////////////////////////////
|
||||||
|
// GameLib_RemoveEntity
|
||||||
|
//
|
||||||
|
// removes the entity.
|
||||||
|
int GameLib_RemoveEntity(Entity e);
|
||||||
|
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
// GameLib_UnrefEntity
|
// GameLib_UnrefEntity
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user