From b8650346b938aea11f81baed2e6e12a17ae2815b Mon Sep 17 00:00:00 2001 From: computermouth Date: Sat, 4 Nov 2023 17:02:31 -0600 Subject: [PATCH] drawing dennis in map1 --- c1k3-assets | 2 +- entity_demon.c | 58 +++++++++++++++++++++++++++++++++++++++++++ entity_demon.h | 9 +++++++ entity_enemy_mutant.c | 3 --- map.c | 4 +++ map.h | 1 + 6 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 entity_demon.c create mode 100644 entity_demon.h diff --git a/c1k3-assets b/c1k3-assets index 99b42a4..e0d06d3 160000 --- a/c1k3-assets +++ b/c1k3-assets @@ -1 +1 @@ -Subproject commit 99b42a46f9c85a8803a12ae87ffe30459ffdbff6 +Subproject commit e0d06d36c99ee4d5e485e7203c99aee40a7e745a diff --git a/entity_demon.c b/entity_demon.c new file mode 100644 index 0000000..802a4ec --- /dev/null +++ b/entity_demon.c @@ -0,0 +1,58 @@ + +#include "entity.h" +#include "game.h" +#include "audio.h" +#include "map.h" +#include "vector.h" + +void entity_demon_init(entity_t * e); +void entity_demon_update(entity_t * e); + +// todo, once animations are actually parse-able +animation_t demon_animations[] = { + { // 0: Idle + .time = 0.5, + .num_frames = 6, + .frames = (animation_frame_t[]) { + {.name = "default"}, + {.name = "breathe.001"}, + {.name = "breathe.002"}, + {.name = "breathe.003"}, + {.name = "breathe.004"}, + {.name = "breathe.005"}, + }, + } +}; + +// hack for caching parsed frame names per-map +static ref_entt_t * last_ref_entt = NULL; + +void entity_demon_constructor(entity_t * e) { + entity_constructor(e); + e->_update = entity_demon_update; + entity_demon_init(e); +} + +void entity_demon_init(entity_t * e) { + + entity_parse_animation_frames( + e->_params->entity_generic_params.ref_entt, + demon_animations, + sizeof(demon_animations)/sizeof(demon_animations[0]), + &last_ref_entt + ); + + e->_animation_collection = (animation_collection_t) { + .animations = demon_animations, + .num_animations = sizeof(demon_animations)/sizeof(demon_animations[0]), + }; + + e->_anim = &(e->_animation_collection.animations[0]); + e->_anim_time = 0; + + entity_set_model(e); +} + +void entity_demon_update(entity_t * e) { + e->_draw_model(e); +} \ No newline at end of file diff --git a/entity_demon.h b/entity_demon.h new file mode 100644 index 0000000..2e32e55 --- /dev/null +++ b/entity_demon.h @@ -0,0 +1,9 @@ + +#ifndef ENTITY_ENEMY_DEMON_H +#define ENTITY_ENEMY_DEMON_H + +#include "entity.h" + +void entity_demon_constructor(entity_t *e); + +#endif diff --git a/entity_enemy_mutant.c b/entity_enemy_mutant.c index 048c963..e46ce6a 100644 --- a/entity_enemy_mutant.c +++ b/entity_enemy_mutant.c @@ -44,9 +44,6 @@ enemy_state_t mutant_enemy_states[_ENEMY_STATE_NULL] = { [ENEMY_STATE_EVADE] = {ENEMY_ANIMATION_IDLE, 0.0, 0.8, _ENEMY_STATE_NULL}, }; -// todo, do something less stupid with this -model_t model_mutant = { 0 }; - void entity_enemy_mutant_constructor(entity_t * e) { entity_enemy_constructor(e, 0); e->_attack = entity_enemy_mutant_attack; diff --git a/map.c b/map.c index 1ec51d5..06c5212 100644 --- a/map.c +++ b/map.c @@ -36,6 +36,7 @@ #include "entity_door.h" #include "entity_pickup_key.h" #include "entity_torch.h" +#include "entity_demon.h" #include "mpack.h" #include "vector.h" @@ -152,6 +153,9 @@ void map_init() { map_entity_table[ENTITY_ID_GIBS006] = (map_entity_table_t) { "gibs.006", entity_particle_constructor }; + map_entity_table[ENTITY_ID_DEMON] = (map_entity_table_t) { + "demon", entity_demon_constructor + }; } typedef void (*constfunc)(entity_t *); diff --git a/map.h b/map.h index 5e51473..9071968 100644 --- a/map.h +++ b/map.h @@ -60,6 +60,7 @@ typedef enum { ENTITY_ID_GIBS004, ENTITY_ID_GIBS005, ENTITY_ID_GIBS006, + ENTITY_ID_DEMON, __ENTITY_ID_END, } entity_id_t;