aboutsummaryrefslogtreecommitdiff
path: root/plugins/monster/monster.c
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2021-06-11 21:21:53 +0200
committerElias Fleckenstein <eliasfleckenstein@web.de>2021-06-11 21:21:53 +0200
commit07b52bfe3f13319dac0d066ba82e127c1bb95616 (patch)
tree6ff34cef1e9f861573bec61e415e8ed6648c6ab5 /plugins/monster/monster.c
parent30c560e271499cb461372a6798e53bf122a7495e (diff)
downloaddungeon_game-07b52bfe3f13319dac0d066ba82e127c1bb95616.tar.xz
Only use entity color if use_color = true
Diffstat (limited to 'plugins/monster/monster.c')
-rw-r--r--plugins/monster/monster.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/plugins/monster/monster.c b/plugins/monster/monster.c
index 890e2bd..02957da 100644
--- a/plugins/monster/monster.c
+++ b/plugins/monster/monster.c
@@ -3,8 +3,6 @@
#include "../game/game.h"
#include "../score/score.h"
-static struct entity monster;
-
struct monster_data
{
double timer;
@@ -41,34 +39,36 @@ static void monster_death(struct entity *self)
self->remove = true;
}
+static struct entity monster_entity = {
+ .name = "monster",
+ .x = 0,
+ .y = 0,
+ .color = {0},
+ .use_color = false,
+ .texture = "👾",
+ .remove = false,
+ .meta = NULL,
+ .health = 5,
+ .max_health = 5,
+ .collide_with_entities = true,
+
+ .on_step = &monster_step,
+ .on_collide = NULL,
+ .on_collide_with_entity = &monster_collide_with_entity,
+ .on_spawn = &monster_spawn,
+ .on_remove = NULL,
+ .on_death = &monster_death,
+ .on_damage = NULL,
+};
+
+
static void spawn_monster(int x, int y)
{
- spawn(monster, x, y, NULL);
+ spawn(monster_entity, x, y, NULL);
}
__attribute__((constructor)) static void init()
{
- monster = (struct entity) {
- .name = "monster",
- .x = 0,
- .y = 0,
- .color = get_color("#FF00F6"),
- .texture = "👾",
- .remove = false,
- .meta = NULL,
- .health = 5,
- .max_health = 5,
- .collide_with_entities = true,
-
- .on_step = &monster_step,
- .on_collide = NULL,
- .on_collide_with_entity = &monster_collide_with_entity,
- .on_spawn = &monster_spawn,
- .on_remove = NULL,
- .on_death = &monster_death,
- .on_damage = NULL,
- };
-
register_air_function((struct generator_function) {
.chance = 50,
.callback = &spawn_monster,