aboutsummaryrefslogtreecommitdiff
path: root/src/pickup.c
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-06-29 21:47:55 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-06-29 21:47:55 +0100
commit2d2379251e71b5f315235db7980d0cfe03132561 (patch)
tree346ddd8719753fa1470cb8dc7456328d033ebff1 /src/pickup.c
parent16fb9f0d5e5904cca7c256b63f20f1fc1466bd5e (diff)
downloadgold-mine-run-2d2379251e71b5f315235db7980d0cfe03132561.tar.gz
gold-mine-run-2d2379251e71b5f315235db7980d0cfe03132561.zip
Add pickaxe pickup
Diffstat (limited to 'src/pickup.c')
-rw-r--r--src/pickup.c24
1 files changed, 18 insertions, 6 deletions
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;
}