Example rendering
This commit is contained in:
@@ -45,4 +45,19 @@ void entityUpdate(entity_t *entity) {
|
||||
assertNotNull(entity, "Entity pointer cannot be NULL");
|
||||
assertTrue(entity->type < ENTITY_TYPE_COUNT, "Invalid entity type");
|
||||
assertTrue(entity->type != ENTITY_TYPE_NULL, "Cannot have NULL entity type");
|
||||
|
||||
// Velocity
|
||||
for(uint8_t i = 0; i < WORLD_DIMENSIONS; i++) {
|
||||
if(entity->velocity[i] == 0) continue;
|
||||
|
||||
worldChunkPosAdd(&entity->position[i], entity->velocity[i]);
|
||||
|
||||
if(entity->velocity[i] < 0) {
|
||||
entity->velocity[i] += ENTITY_FRICTION;
|
||||
if(entity->velocity[i] >= -ENTITY_MIN_VELOCITY) entity->velocity[i] = 0;
|
||||
} else {
|
||||
entity->velocity[i] -= ENTITY_FRICTION;
|
||||
if(entity->velocity[i] <= ENTITY_MIN_VELOCITY) entity->velocity[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user