pathfinding with bfs

This commit is contained in:
2026-07-04 18:01:22 -07:00
parent 6697ba70bf
commit ca2ea3397d
5 changed files with 154 additions and 17 deletions
+16 -3
View File
@@ -9,11 +9,16 @@ Tilemap :: struct {
}
tilemap_init :: proc() -> Tilemap {
return Tilemap {
width = MAP_WIDTH,
tm := Tilemap {
width = MAP_WIDTH,
height = MAP_HEIGHT,
tiles = make([]u8, MAP_WIDTH * MAP_HEIGHT),
tiles = make([]u8, MAP_WIDTH * MAP_HEIGHT),
}
// test wall
for x in 15 ..< 25 {
tm.tiles[tile_index(&tm, x, 12)] = 1
}
return tm
}
tilemap_destroy :: proc(tilemap: ^Tilemap) {
@@ -74,3 +79,11 @@ tilemap_draw :: proc(tilemap: ^Tilemap, camera: ^Camera2D) {
}
}
tile_walkable :: proc(tilemap: ^Tilemap, x, y: int) -> bool {
if !tile_in_bounds(tilemap, x, y) {return false}
idx := tile_index(tilemap, x, y)
return tilemap.tiles[idx] != 1
}