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,
23 static void cherry_step(struct entity *self, struct entity_step_data stepdata)
25 if (stepdata.dx == 0 && stepdata.dy == 0) {
27 inventory_add(&player_inventory, (struct itemstack) {
36 static struct entity cherry_entity = {
47 .collide_with_entities = false,
49 .on_step = &cherry_step,
51 .on_collide_with_entity = NULL,
58 static void spawn_cherry(int x, int y)
60 spawn(cherry_entity, x, y, NULL);
63 __attribute__((constructor)) static void init()
65 register_air_function((struct generator_function) {
67 .callback = &spawn_cherry,