3 #include "../game/game.h"
4 #include "../score/score.h"
5 #include "../inventory/inventory.h"
7 static bool use_cherry(struct itemstack *stack)
11 add_health(&player, 2);
15 static struct item cherry_item = {
19 .on_use = &use_cherry,
24 static void cherry_step(struct entity *self, struct entity_step_data stepdata)
26 if (stepdata.dx == 0 && stepdata.dy == 0) {
28 inventory_add(&player_inventory, (struct itemstack) {
37 static struct entity cherry_entity = {
48 .collide_with_entities = false,
50 .on_step = &cherry_step,
52 .on_collide_with_entity = NULL,
59 static void spawn_cherry(int x, int y)
61 spawn(cherry_entity, x, y, NULL);
64 __attribute__((constructor)) static void init()
66 register_air_function((struct generator_function) {
68 .callback = &spawn_cherry,