Input test.
This commit is contained in:
@@ -12,12 +12,11 @@
|
||||
entity_t ENTITIES[ENTITY_COUNT];
|
||||
|
||||
entitycallbacks_t ENTITY_CALLBACKS[ENTITY_TYPE_COUNT] = {
|
||||
[ENTITY_TYPE_NULL] = {
|
||||
.init = NULL
|
||||
},
|
||||
[ENTITY_TYPE_NULL] = { 0 },
|
||||
|
||||
[ENTITY_TYPE_PLAYER] = {
|
||||
.init = playerInit
|
||||
.init = playerInit,
|
||||
.update = playerUpdate
|
||||
},
|
||||
};
|
||||
|
||||
@@ -31,4 +30,23 @@ void entityInit(entity_t *entity, const entitytype_t type) {
|
||||
memoryZero(entity, sizeof(entity_t));
|
||||
entity->type = type;
|
||||
ENTITY_CALLBACKS[type].init(entity);
|
||||
}
|
||||
|
||||
void entityUpdate(entity_t *entity) {
|
||||
assertNotNull(entity, "Entity cannot be NULL");
|
||||
assertNotNull(
|
||||
ENTITY_CALLBACKS[entity->type].update,
|
||||
"Entity type has no update"
|
||||
);
|
||||
|
||||
ENTITY_CALLBACKS[entity->type].update(entity);
|
||||
}
|
||||
|
||||
entity_t * entityGetAt(const uint8_t x, const uint8_t y) {
|
||||
entity_t *e = ENTITIES;
|
||||
do {
|
||||
if(e->type && e->x == x && e->y == y) return e;
|
||||
e++;
|
||||
} while(e < (ENTITIES + ENTITY_COUNT));
|
||||
return NULL;
|
||||
}
|
||||
Reference in New Issue
Block a user