diff --git a/c1k3-assets b/c1k3-assets index 29e3d53..7d2251e 160000 --- a/c1k3-assets +++ b/c1k3-assets @@ -1 +1 @@ -Subproject commit 29e3d530403bfcbff353a3233786439581490602 +Subproject commit 7d2251eae1f15292976067aff58f371a6381046e diff --git a/entity_demon.h b/entity_demon.h index ee4ab4d..8caa009 100644 --- a/entity_demon.h +++ b/entity_demon.h @@ -1,6 +1,6 @@ -#ifndef ENTITY_ENEMY_DEMON_H -#define ENTITY_ENEMY_DEMON_H +#ifndef ENTITY_DEMON_H +#define ENTITY_DEMON_H #include "entity.h" diff --git a/entity_minobaur.c b/entity_minobaur.c new file mode 100644 index 0000000..18703c8 --- /dev/null +++ b/entity_minobaur.c @@ -0,0 +1,145 @@ + +#include "entity.h" +#include "game.h" +#include "audio.h" +#include "map.h" +#include "vector.h" + +void entity_minobaur_init(entity_t * e); +void entity_minobaur_update(entity_t * e); + +animation_t minobaur_animations[] = { + { // 0: T pose + .time = 0.5, + .num_frames = 1, + .frames = (animation_frame_t[]) { + {.name = "default"}, + }, + }, + { // 1: Swipe + .time = 0.09, + .num_frames = 20, + .frames = (animation_frame_t[]) { + {.name = "swipe.000"}, + {.name = "swipe.001"}, + {.name = "swipe.002"}, + {.name = "swipe.003"}, + {.name = "swipe.004"}, + {.name = "swipe.005"}, + {.name = "swipe.006"}, + {.name = "swipe.007"}, + {.name = "swipe.008"}, + {.name = "swipe.009"}, + {.name = "swipe.010"}, + {.name = "swipe.011"}, + {.name = "swipe.012"}, + {.name = "swipe.013"}, + {.name = "swipe.014"}, + {.name = "swipe.015"}, + {.name = "swipe.016"}, + {.name = "swipe.017"}, + {.name = "swipe.018"}, + {.name = "swipe.019"}, + }, + }, + { // 2: Charge + .time = 0.10, + .num_frames = 5, + .frames = (animation_frame_t[]) { + {.name = "charge.000"}, + {.name = "charge.001"}, + {.name = "charge.002"}, + {.name = "charge.003"}, + {.name = "charge.004"}, + }, + }, + { // 3: Land + .time = .50, + .num_frames = 7, + .frames = (animation_frame_t[]) { + {.name = "land.000"}, + {.name = "land.000"}, + {.name = "land.000"}, + {.name = "land.000"}, + {.name = "land.001"}, + {.name = "land.002"}, + {.name = "land.003"}, + {.name = "land.004"}, + {.name = "swipe.000"}, + }, + }, + { // 4: Die + .time = 0.15, + .num_frames = 20, + .frames = (animation_frame_t[]) { + {.name = "die.000"}, + {.name = "die.001"}, + {.name = "die.002"}, + {.name = "die.003"}, + {.name = "die.004"}, + {.name = "die.005"}, + {.name = "die.006"}, + {.name = "die.007"}, + {.name = "die.008"}, + {.name = "die.009"}, + {.name = "die.010"}, + {.name = "die.011"}, + {.name = "die.012"}, + {.name = "die.013"}, + {.name = "die.013"}, + {.name = "die.013"}, + {.name = "die.013"}, + {.name = "die.013"}, + {.name = "die.013"}, + {.name = "die.013"}, + }, + }, + { // 5: Bump + .time = 0.12, + .num_frames = 9, + .frames = (animation_frame_t[]) { + {.name = "bump.000"}, + {.name = "bump.001"}, + {.name = "bump.002"}, + {.name = "bump.003"}, + {.name = "bump.004"}, + {.name = "bump.005"}, + {.name = "bump.006"}, + {.name = "bump.007"}, + {.name = "bump.008"}, + }, + }, +}; + +// hack for caching parsed frame names per-map +static ref_entt_t * last_ref_entt = NULL; + +void entity_minobaur_constructor(entity_t * e) { + entity_constructor(e); + e->_update = entity_minobaur_update; + entity_minobaur_init(e); +} + +void entity_minobaur_init(entity_t * e) { + + entity_parse_animation_frames( + e->_params->entity_generic_params.ref_entt, + minobaur_animations, + sizeof(minobaur_animations)/sizeof(minobaur_animations[0]), + &last_ref_entt + ); + + e->_animation_collection = (animation_collection_t) { + .animations = minobaur_animations, + .num_animations = sizeof(minobaur_animations)/sizeof(minobaur_animations[0]), + }; + + e->_anim = &(e->_animation_collection.animations[1]); + e->_anim_time = 0; + + entity_set_model(e); +} + +void entity_minobaur_update(entity_t * e) { + e->_draw_model(e); +} \ No newline at end of file diff --git a/entity_minobaur.h b/entity_minobaur.h new file mode 100644 index 0000000..ee8437f --- /dev/null +++ b/entity_minobaur.h @@ -0,0 +1,10 @@ + +#ifndef ENTITY_MINOBAUR_H +#define ENTITY_MINOBAUR_H + +#include "entity.h" + +void entity_minobaur_constructor(entity_t *e); +void entity_minobaur_update(entity_t * e); + +#endif diff --git a/main.c b/main.c index 5bad822..5826340 100644 --- a/main.c +++ b/main.c @@ -19,6 +19,7 @@ #include "text.h" #include "vector.h" #include "entity_demon.h" +#include "entity_minobaur.h" void game_load() { // text has to come before render init @@ -53,20 +54,35 @@ text_surface_t * c1k3 = NULL; text_surface_t * dq = NULL; text_surface_t * dennis = NULL; entity_t * demon = NULL; +entity_t * minobaur = NULL; void menu_init() { // set level to menu map_set_level(2); - entity_params_t d = { - .id = ENTITY_ID_DEMON, - .position = vec3(0,-12,-18), - .entity_generic_params.ref_entt = map_ref_entt_from_eid(ENTITY_ID_DEMON), - }; - demon = calloc(sizeof(entity_t), 1); - demon->_params = &d; - demon->_yaw = PI * 36.0f/40.0f; - entity_demon_constructor(demon); + { + entity_params_t d = { + .id = ENTITY_ID_DEMON, + .position = vec3(0,-12,-18), + .entity_generic_params.ref_entt = map_ref_entt_from_eid(ENTITY_ID_DEMON), + }; + demon = calloc(sizeof(entity_t), 1); + demon->_params = &d; + demon->_yaw = PI * 36.0f/40.0f; + entity_demon_constructor(demon); + } + + { + entity_params_t mb = { + .id = ENTITY_ID_MINOBAUR, + .position = vec3(0,0,32), + .entity_generic_params.ref_entt = map_ref_entt_from_eid(ENTITY_ID_MINOBAUR), + }; + minobaur = calloc(sizeof(entity_t), 1); + minobaur->_params = &mb; + minobaur->_yaw = PI; + entity_minobaur_constructor(minobaur); + } } void menu_run(float time_now) { @@ -107,7 +123,8 @@ void menu_run(float time_now) { r_prepare_frame(0.0f, 0.0f, 0.0f); - entity_demon_update(demon); + // entity_demon_update(demon); + entity_minobaur_update(minobaur); // ref_entt_t * re = map_ref_entt_from_eid(ENTITY_ID_TORCH); // uint32_t * uframes = vector_begin(re->frames); @@ -240,6 +257,8 @@ int main(int argc, char* argv[]) { text_free_surface(dennis); if (demon) free(demon); + if (minobaur) + free(minobaur); } // perform based on state diff --git a/map.c b/map.c index cb48b45..73dd8b8 100644 --- a/map.c +++ b/map.c @@ -37,6 +37,7 @@ #include "entity_pickup_key.h" #include "entity_torch.h" #include "entity_demon.h" +#include "entity_minobaur.h" #include "mpack.h" #include "vector.h" @@ -156,6 +157,9 @@ void map_init() { map_entity_table[ENTITY_ID_DEMON] = (map_entity_table_t) { "demon", entity_demon_constructor }; + map_entity_table[ENTITY_ID_MINOBAUR] = (map_entity_table_t) { + "minobaur", entity_minobaur_constructor + }; } typedef void (*constfunc)(entity_t *); diff --git a/map.h b/map.h index 3089af0..940a4c9 100644 --- a/map.h +++ b/map.h @@ -61,6 +61,7 @@ typedef enum { ENTITY_ID_GIBS005, ENTITY_ID_GIBS006, ENTITY_ID_DEMON, + ENTITY_ID_MINOBAUR, __ENTITY_ID_END, } entity_id_t;