diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2021-06-09 19:41:18 +0200 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2021-06-09 19:41:18 +0200 |
commit | 043c0a4c0ef016e3b49816d582cdf7227f6d3450 (patch) | |
tree | fe171f949c5dc59d47ecf882369ee3ae4cd905f1 /plugins/monster | |
parent | 9a897a11d49b21f54e338cf82a6a79fd19f797a3 (diff) | |
download | dungeon_game-043c0a4c0ef016e3b49816d582cdf7227f6d3450.tar.xz |
Add fireballs
Diffstat (limited to 'plugins/monster')
-rw-r--r-- | plugins/monster/monster.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/plugins/monster/monster.c b/plugins/monster/monster.c index 7124c76..59fa380 100644 --- a/plugins/monster/monster.c +++ b/plugins/monster/monster.c @@ -9,8 +9,10 @@ struct monster_data double timer; }; -static void monster_spawn(struct entity *self) +static void monster_spawn(struct entity *self, void *data) { + (void) data; + self->meta = malloc(sizeof(struct monster_data)); ((struct monster_data *) self->meta)->timer = 0.5; } @@ -26,7 +28,7 @@ static void monster_step(struct entity *self, struct entity_step_data stepdata) } } -static void monster_on_collide_with_entity(struct entity *self, struct entity *other) +static void monster_collide_with_entity(struct entity *self, struct entity *other) { if (other == &player) add_health(other, -1); @@ -40,7 +42,7 @@ static void monster_death(struct entity *self) static void spawn_monster(int x, int y) { - spawn(monster, x, y); + spawn(monster, x, y, NULL); } __attribute__((constructor)) static void init() @@ -59,7 +61,7 @@ __attribute__((constructor)) static void init() .on_step = &monster_step, .on_collide = NULL, - .on_collide_with_entity = &monster_on_collide_with_entity, + .on_collide_with_entity = &monster_collide_with_entity, .on_spawn = &monster_spawn, .on_remove = NULL, .on_death = &monster_death, |