aboutsummaryrefslogtreecommitdiff
path: root/src/player.c
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-06-25 22:44:23 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-06-25 22:44:23 +0100
commit6bd6757583510ba3edf75451309e4b8ec8c9b0f1 (patch)
treee63f401238e4118ff6d1670ea86508f0181c19ea /src/player.c
parent2d7fbc07acf0c5766d662d2629e72600b65f744b (diff)
downloadgold-mine-run-6bd6757583510ba3edf75451309e4b8ec8c9b0f1.tar.gz
gold-mine-run-6bd6757583510ba3edf75451309e4b8ec8c9b0f1.zip
Add entity system, add new enemy (snake)
Diffstat (limited to 'src/player.c')
-rw-r--r--src/player.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/player.c b/src/player.c
index 856cafd..ae50348 100644
--- a/src/player.c
+++ b/src/player.c
@@ -6,17 +6,14 @@
#include "data.h"
#include "game.h"
+#include "entities.h"
#include "player.h"
-#define DIR_RIGHT 0
-#define DIR_LEFT 1
-
#define FRAME_STANDING 0
#define FRAME_JUMPING 4
#define FRAME_DYING 5
#define WALK_CYCLE_FRAMES 4
-#define WALK_DELAY 8
#define GRAVITY_OFF 0
/* XXX: subtract 1 to get the value from gravity_seq */
@@ -298,6 +295,18 @@ void player_draw()
blitrc(binary_sprites_start, &frames[dir][frame], &dst);
}
+uint8_t player_collision(Entity *e)
+{
+ if (invuln || dying)
+ return 0;
+
+ if (y < e->y + 16 && e->y < y + 16
+ && x < e->x + 8 && e->x < x + 8)
+ return 1;
+
+ return 0;
+}
+
void player_hit()
{
/* TODO: pickaxe */