3 #include "../game/game.h"
4 #include "../score/score.h"
5 #include "../inventory/inventory.h"
6 #include "../loot/loot.h"
8 static bool use_cherry(struct itemstack *stack)
10 add_health(&player, 2);
14 static struct item cherry_item = {
18 .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, enum mg_context ctx)
60 spawn(cherry_entity, x, y, NULL);
63 __attribute__((constructor)) static void init()
65 register_air_function((struct generator_function) {
66 .corridor_chance = 100,
68 .callback = &spawn_cherry,
71 register_loot((struct loot) {