diff options
Diffstat (limited to 'plugins/apple')
-rw-r--r-- | plugins/apple/Makefile | 2 | ||||
-rw-r--r-- | plugins/apple/apple.c | 48 | ||||
-rw-r--r-- | plugins/apple/dependencies.txt | 2 |
3 files changed, 27 insertions, 25 deletions
diff --git a/plugins/apple/Makefile b/plugins/apple/Makefile index 33c3303..f90b872 100644 --- a/plugins/apple/Makefile +++ b/plugins/apple/Makefile @@ -1,4 +1,4 @@ -plugins/apple/apple.so: plugins/apple/apple.c plugins/game/game.h +plugins/apple/apple.so: plugins/apple/apple.c plugins/game/game.h plugins/score/score.h cc -g -shared -fpic -o plugins/apple/apple.so plugins/apple/apple.c PLUGINS := ${PLUGINS} plugins/apple/apple.so diff --git a/plugins/apple/apple.c b/plugins/apple/apple.c index d100e45..795800d 100644 --- a/plugins/apple/apple.c +++ b/plugins/apple/apple.c @@ -1,8 +1,7 @@ #include <stddef.h> #include <stdlib.h> #include "../game/game.h" - -static struct entity apple; +#include "../score/score.h" static void apple_step(struct entity *self, struct entity_step_data stepdata) { @@ -13,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, diff --git a/plugins/apple/dependencies.txt b/plugins/apple/dependencies.txt new file mode 100644 index 0000000..3914551 --- /dev/null +++ b/plugins/apple/dependencies.txt @@ -0,0 +1,2 @@ +game +score |