]> git.lizzy.rs Git - dungeon_game.git/blobdiff - plugins/cherry/cherry.c
Only use entity color if use_color = true
[dungeon_game.git] / plugins / cherry / cherry.c
index 072aec077b6592121c6ff64e9bde665dab38d6c4..436fcf941bfd8036e024aee3dbe92ab6fc7bd378 100644 (file)
@@ -4,8 +4,6 @@
 #include "../score/score.h"
 #include "../inventory/inventory.h"
 
-static struct entity cherry_entity;
-
 static bool use_cherry(struct itemstack *stack)
 {
        (void) stack;
@@ -35,6 +33,28 @@ static void cherry_step(struct entity *self, struct entity_step_data stepdata)
        }
 }
 
+static struct entity cherry_entity = {
+       .name = "cherry",
+       .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 = &cherry_step,
+       .on_collide = NULL,
+       .on_collide_with_entity = NULL,
+       .on_spawn = NULL,
+       .on_remove = NULL,
+       .on_death = NULL,
+       .on_damage = NULL,
+};
+
 static void spawn_cherry(int x, int y)
 {
        spawn(cherry_entity, x, y, NULL);
@@ -42,27 +62,6 @@ static void spawn_cherry(int x, int y)
 
 __attribute__((constructor)) static void init()
 {
-       cherry_entity = (struct entity) {
-               .name = "cherry",
-               .x = 0,
-               .y = 0,
-               .color = get_color("#FF2A53"),
-               .texture = "🍒",
-               .remove = false,
-               .meta = NULL,
-               .health = 1,
-               .max_health = 1,
-               .collide_with_entities = false,
-
-               .on_step = &cherry_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 = 100,
                .callback = &spawn_cherry,