3 #include "../game/game.h"
4 #include "../score/score.h"
5 #include "../inventory/inventory.h"
7 static bool use_cherry(struct itemstack *stack)
9 add_health(&player, 2);
13 static struct item cherry_item = {
17 .on_use = &use_cherry,
22 static void cherry_step(struct entity *self, struct entity_step_data stepdata)
24 if (stepdata.dx == 0 && stepdata.dy == 0) {
26 inventory_add(&player_inventory, (struct itemstack) {
35 static struct entity cherry_entity = {
46 .collide_with_entities = false,
48 .on_step = &cherry_step,
50 .on_collide_with_entity = NULL,
57 static void spawn_cherry(int x, int y, enum mg_context ctx)
59 spawn(cherry_entity, x, y, NULL);
62 __attribute__((constructor)) static void init()
64 register_air_function((struct generator_function) {
65 .corridor_chance = 100,
67 .callback = &spawn_cherry,