diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2021-06-11 21:21:53 +0200 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2021-06-11 21:21:53 +0200 |
commit | 07b52bfe3f13319dac0d066ba82e127c1bb95616 (patch) | |
tree | 6ff34cef1e9f861573bec61e415e8ed6648c6ab5 /plugins/apple/apple.c | |
parent | 30c560e271499cb461372a6798e53bf122a7495e (diff) | |
download | dungeon_game-07b52bfe3f13319dac0d066ba82e127c1bb95616.tar.xz |
Only use entity color if use_color = true
Diffstat (limited to 'plugins/apple/apple.c')
-rw-r--r-- | plugins/apple/apple.c | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/plugins/apple/apple.c b/plugins/apple/apple.c index 19e2e00..795800d 100644 --- a/plugins/apple/apple.c +++ b/plugins/apple/apple.c @@ -3,8 +3,6 @@ #include "../game/game.h" #include "../score/score.h" -static struct entity apple; - static void apple_step(struct entity *self, struct entity_step_data stepdata) { if (stepdata.dx == 0 && stepdata.dy == 0) { @@ -14,34 +12,35 @@ static void apple_step(struct entity *self, struct entity_step_data stepdata) } } +static struct entity apple_entity = { + .name = "apple", + .x = 0, + .y = 0, + .color = {0}, + .use_color = false, + .texture = "🍎", + .remove = false, + .meta = NULL, + .health = 1, + .max_health = 1, + .collide_with_entities = false, + + .on_step = &apple_step, + .on_collide = NULL, + .on_collide_with_entity = NULL, + .on_spawn = NULL, + .on_remove = NULL, + .on_death = NULL, + .on_damage = NULL, +}; + static void spawn_apple(int x, int y) { - spawn(apple, x, y, NULL); + spawn(apple_entity, x, y, NULL); } __attribute__((constructor)) static void init() { - apple = (struct entity) { - .name = "apple", - .x = 0, - .y = 0, - .color = get_color("#FF2A53"), - .texture = "🍎", - .remove = false, - .meta = NULL, - .health = 1, - .max_health = 1, - .collide_with_entities = false, - - .on_step = &apple_step, - .on_collide = NULL, - .on_collide_with_entity = NULL, - .on_spawn = NULL, - .on_remove = NULL, - .on_death = NULL, - .on_damage = NULL, - }; - register_air_function((struct generator_function) { .chance = 25, .callback = &spawn_apple, |