diff options
Diffstat (limited to 'src/entity.c')
| -rw-r--r-- | src/entity.c | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/src/entity.c b/src/entity.c index d737ea9..84ce609 100644 --- a/src/entity.c +++ b/src/entity.c @@ -29,10 +29,18 @@ Rectangle get_entity_dest_rect_world(const struct entity* entity) { void entity_handle_collision ( - struct entity*, - struct entity*, - enum direction + struct entity* self, + struct entity* other, + enum direction direction ) { + switch (self->type) { + case Player_Entity: + player_handle_collision(self, other, direction); + break; + + default: + break; + } } static inline bool entity_animated(const struct entity* e) { @@ -67,32 +75,38 @@ Rectangle animation_get_source_rect(const struct animation* animation) { } void draw_entity_default(const struct entity* entity) { + Rectangle source_rect; + if (entity_animated(entity)) { const struct animation* current_animation = &entity->animations[entity->current_animation]; - DrawTexturePro(entity->texture, - animation_get_source_rect(current_animation), - get_entity_dest_rect_world(entity), - (Vector2) {0.0, 0.0}, - 0, - WHITE); + source_rect = animation_get_source_rect(current_animation); } else { - DrawTexturePro(entity->texture, - entity->sprite_source_rect, - get_entity_dest_rect_world(entity), - (Vector2) {0.0, 0.0}, - 0, - WHITE); + source_rect = entity->sprite_source_rect; } + + if (entity->flip) { + source_rect.width *= -1; + } + + DrawTexturePro(entity->texture, + source_rect, + get_entity_dest_rect_world(entity), + (Vector2) {0.0, 0.0}, + 0, + WHITE); } void draw_entity(const struct entity* entity) { - switch (entity->type) { - case Wall_Entity: - draw_wall(entity); - break; + /* if (entity->flags & ENTITY_COLLISION_ACTIVE) { */ + /* DrawRectangleRec( */ + /* get_entity_collider_world(entity), */ + /* RED */ + /* ); */ + /* } */ + switch (entity->type) { default: draw_entity_default(entity); break; |
