Skip to content

Commit

Permalink
drawing dennis in map1
Browse files Browse the repository at this point in the history
  • Loading branch information
computermouth committed Nov 4, 2023
1 parent 0087ab9 commit b865034
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 4 deletions.
58 changes: 58 additions & 0 deletions entity_demon.c
Original file line number Diff line number Diff line change
@@ -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);
}
9 changes: 9 additions & 0 deletions entity_demon.h
Original file line number Diff line number Diff line change
@@ -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
3 changes: 0 additions & 3 deletions entity_enemy_mutant.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions map.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 *);
Expand Down
1 change: 1 addition & 0 deletions map.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ typedef enum {
ENTITY_ID_GIBS004,
ENTITY_ID_GIBS005,
ENTITY_ID_GIBS006,
ENTITY_ID_DEMON,
__ENTITY_ID_END,
} entity_id_t;

Expand Down

0 comments on commit b865034

Please sign in to comment.