Files
tower-defense-prototype/game/map.odin
T
2026-06-10 02:32:01 -07:00

57 lines
921 B
Odin

package game
import rl "vendor:raylib"
Tile_Kind :: enum {
Blocked,
Path,
Build,
}
Map :: struct {
tiles: [MAP_H][MAP_W]Tile_Kind,
}
tile_color :: proc(kind: Tile_Kind) -> rl.Color {
switch kind {
case .Blocked:
return {35, 95, 35, 255}
case .Path:
return {130, 85, 45, 255}
case .Build:
return {50, 130, 50, 255}
}
return rl.MAGENTA
}
init_map :: proc(world_map: ^Map) {
for y in 0 ..< MAP_H {
for x in 0 ..< MAP_W {
world_map.tiles[y][x] = .Blocked
}
}
for x in 1 ..< 13 {
world_map.tiles[6][x] = .Path
}
for y in 7 ..< 8 {
world_map.tiles[y][12] = .Path
}
for y in 4 ..< 9 {
for x in 3 ..< 12 {
if world_map.tiles[y][x] != .Path {
world_map.tiles[y][x] = .Build
}
}
}
}
can_build_at :: proc(world_map: ^Map, gx, gy: int) -> bool {
if gx < 0 || gx >= MAP_W do return false
if gy < 0 || gy >= MAP_H do return false
return world_map.tiles[gy][gx] == .Build
}