summaryrefslogtreecommitdiff
path: root/src/entity.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/entity.h')
-rw-r--r--src/entity.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/entity.h b/src/entity.h
index 94eb00f..ac179c1 100644
--- a/src/entity.h
+++ b/src/entity.h
@@ -9,6 +9,7 @@
#define ENTITY_ACTIVE 1
#define ENTITY_COLLISION_ACTIVE (1 << 1)
#define ENTITY_VISIBLE (1 << 2)
+#define ENTITY_ANIMATED (1 << 3)
enum entity_type {
Player_Entity
@@ -38,6 +39,9 @@ struct animation {
float current_frame_time;
};
+void update_animation(struct animation* animation, float dt);
+Rectangle get_current_srcrect(const struct animation* animation);
+
struct entity {
int entity_id;
enum entity_type type;
@@ -48,6 +52,7 @@ struct entity {
Rectangle collider;
Texture texture;
+ Rectangle sprite_source_rect; //Used if entity doesn't have sprite animations
Rectangle sprite_dest_rect; //Relative to the position of entity (roughly the center)
struct animation animations[ENTITY_MAX_ANIMATIONS];
int current_animation;
@@ -69,7 +74,7 @@ void entity_handle_collision
void add_entity(const struct entity* e);
static inline bool entity_active(const struct entity* e) {
- return e->flags & ENTITY_ACTIVE;
+ return (e->flags & ENTITY_ACTIVE) != 0;
}
static inline bool same_entity(const struct entity* a, const struct entity* b) {
@@ -77,7 +82,7 @@ static inline bool same_entity(const struct entity* a, const struct entity* b) {
}
static inline bool entity_visible(const struct entity* e) {
- return e->flags & ENTITY_VISIBLE;
+ return (e->flags & ENTITY_VISIBLE) != 0;
}
#endif