summary refs log tree commit diff
path: root/src/tilemap.c
diff options
context:
space:
mode:
authorzlago2024-10-01 20:17:17 +0200
committerzlago2024-10-01 20:17:17 +0200
commitb687574d705dd6643501e37455932b6e504dd232 (patch)
tree1c44c26c502af7372258a693f822e7414db7ffa6 /src/tilemap.c
parente4ad2c9362254ab3213c4cb7c743b6bbd72b6346 (diff)
move player origin to bottom center
Diffstat (limited to 'src/tilemap.c')
-rw-r--r--src/tilemap.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/tilemap.c b/src/tilemap.c
index ea53e2f..e7ee1d4 100644
--- a/src/tilemap.c
+++ b/src/tilemap.c
@@ -71,13 +71,17 @@ collision_T tilemap_area(struct tilemap *tilemap, int x1, int y1, int x2, int y2
 	if (x1 < 0) {
 		x1 = 0;
 	}
-	if (x2 >= tilemap->width) {
+	if (x2 < 0) {
+		x2 = 0;
+	} else if (x2 >= tilemap->width) {
 		x2 = tilemap->width - 1;
 	}
 	if (y1 < 0) {
 		y1 = 0;
 	}
-	if (y2 >= tilemap->height) {
+	if (y2 < 0) { // for some reason you can bonk your head on nothing without this
+		y2 = 0;
+	} else if (y2 >= tilemap->height) {
 		y2 = tilemap->height - 1;
 	}
 	return tilemap_area_raw(tilemap, x1, y1, x2, y2);