From 2c2be83a370318ca69824538ed3e61784295a772 Mon Sep 17 00:00:00 2001 From: BoredGuy Date: Sun, 15 Mar 2026 17:30:54 +0300 Subject: More work --- src/entity.h | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'src/entity.h') diff --git a/src/entity.h b/src/entity.h index 2ed443f..94eb00f 100644 --- a/src/entity.h +++ b/src/entity.h @@ -4,11 +4,21 @@ #include #include #include +#include "constants.h" + +#define ENTITY_ACTIVE 1 +#define ENTITY_COLLISION_ACTIVE (1 << 1) +#define ENTITY_VISIBLE (1 << 2) enum entity_type { Player_Entity }; +enum draw_layer { + Foreground_Layer, + Background_Layer +}; + enum direction { Direction_Up, Direction_Down, @@ -16,8 +26,17 @@ enum direction { Direction_Right }; -#define ENTITY_ACTIVE 1 -#define ENTITY_COLLISION_ACTIVE (1 << 1) +struct animation { + int frame_count; + bool is_looping; + bool is_completed; + + Rectangle source_rects[ANIMATION_MAX_FRAMES]; + float frame_times[ANIMATION_MAX_FRAMES]; + + int current_frame; + float current_frame_time; +}; struct entity { int entity_id; @@ -27,6 +46,12 @@ struct entity { Vector2 position; //The position of the entity(roughly the center) Vector2 velocity; Rectangle collider; + + Texture texture; + Rectangle sprite_dest_rect; //Relative to the position of entity (roughly the center) + struct animation animations[ENTITY_MAX_ANIMATIONS]; + int current_animation; + enum draw_layer draw_layer; }; void update_entity(struct entity* entity, float dt); @@ -38,7 +63,8 @@ void entity_handle_collision ( struct entity* self, struct entity* other, - enum direction collision_direction); + enum direction collision_direction + ); void add_entity(const struct entity* e); @@ -50,4 +76,8 @@ static inline bool same_entity(const struct entity* a, const struct entity* b) { return a->entity_id == b->entity_id; } +static inline bool entity_visible(const struct entity* e) { + return e->flags & ENTITY_VISIBLE; +} + #endif -- cgit v1.2.3