From 2d2379251e71b5f315235db7980d0cfe03132561 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Thu, 29 Jun 2023 21:47:55 +0100 Subject: Add pickaxe pickup --- src/pickup.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/pickup.c') diff --git a/src/pickup.c b/src/pickup.c index 6b53cda..e1ad424 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -44,7 +44,7 @@ static const Rect frames[2 * 4] = { 80, 16, 144, 144 }, /* pickaxe */ - { 16, 32, 144, 144 }, + { 64, 16, 144, 144 }, /* gold key */ { 0, 0, 144, 144 }, @@ -122,6 +122,14 @@ void pickup_bonus_init(Entity *e) e->update = pickup_wait_update; } +void pickup_pickaxe_init(Entity *e) +{ + e->frames = (const Rect *)frames_in; + e->flags = PICKUP_PICKAXE; + e->counter = MAX_TTL / 2 + (rand() % MAX_TTL); + e->update = pickup_wait_update; +} + void pickup_wait_update(Entity *e) { if (e->counter-- == 0) @@ -141,17 +149,18 @@ void pickup_in_update(Entity *e) case PICKUP_TIME: e->frames = (const Rect *)frames; e->frame = 0; - e->counter = 0; - e->update = pickup_update; break; case PICKUP_BONUS: e->frames = (const Rect *)frames_bonuses[rand() % 3]; e->frame = 0; - e->counter = 0; - e->update = pickup_update; + break; + case PICKUP_PICKAXE: + e->frames = (const Rect *)frames; + e->frame = 1; break; } - + e->counter = 0; + e->update = pickup_update; } } } @@ -189,6 +198,9 @@ void pickup_update(Entity *e) case PICKUP_BONUS: add_score(250); break; + case PICKUP_PICKAXE: + add_pickaxe(); + break; } e->used = 0; } -- cgit v1.2.3