Browse Source

Fix tile coordinate when checking collision

master
Forest Belton 2 years ago
parent
commit
55f0a22107
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      src/collision.c

+ 2
- 2
src/collision.c View File

@ -23,12 +23,12 @@ uint8_t get_tile_coord(uint8_t pixel_coord) {
}
uint8_t player_bg_collides(void) {
const int8_t map_x = PLAYER.x / 8 + MAP.camera_x;
const int8_t map_x = get_tile_coord(PLAYER.x) + MAP.camera_x;
if (map_x < 0 || map_x + 1 >= MAP.map_width) {
return 1;
}
const int8_t map_y = PLAYER.y_hi / 8 + MAP.camera_y;
const int8_t map_y = get_tile_coord(PLAYER.y_hi) + MAP.camera_y;
if (map_y < 0 || map_y + 1 >= MAP.map_height) {
return 1;
}

Loading…
Cancel
Save