3 #include "../game/game.h"
4 #include "../score/score.h"
5 #include "../inventory/inventory.h"
7 static struct entity cherry_entity;
9 static bool use_cherry(struct itemstack *stack)
13 add_health(&player, 2);
17 static struct item cherry_item = {
21 .on_use = &use_cherry,
25 static void cherry_step(struct entity *self, struct entity_step_data stepdata)
27 if (stepdata.dx == 0 && stepdata.dy == 0) {
29 inventory_add(&player_inventory, (struct itemstack) {
38 static void spawn_cherry(int x, int y)
40 spawn(cherry_entity, x, y, NULL);
43 __attribute__((constructor)) static void init()
45 cherry_entity = (struct entity) {
49 .color = get_color("#FF2A53"),
55 .collide_with_entities = false,
57 .on_step = &cherry_step,
59 .on_collide_with_entity = NULL,
66 register_air_function((struct generator_function) {
68 .callback = &spawn_cherry,