Added bounds check for collision detection.

This commit is contained in:
2026-07-26 21:44:16 +02:00
parent c8f3a490ee
commit 5e2b954d1a
+4
View File
@@ -149,6 +149,10 @@ check_map_collision :: proc(rect: rl.Rectangle, game_map: Game_Map) -> bool {
// check all points along the x axis per y axis 'row'
for gy := min_grid[1]; gy <= max_grid[1]; gy += 1 {
for gx := min_grid[0]; gx <= max_grid[0]; gx += 1 {
// bounds check
if gx < 0 || gx >= game_map.width || gy < 0 || gy >= game_map.height do continue
idx := (gy * game_map.width) + gx
tile := Tile_Type(game_map.data[idx])
def := tile_defs[tile]