Files
2026-06-14 00:44:38 -07:00

66 lines
1.1 KiB
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 9 ..< 21 {
world_map.tiles[10][x] = .Path
}
for y in 11 ..< 14 {
world_map.tiles[y][20] = .Path
}
for y in 7 ..< 15 {
for x in 6 ..< 24 {
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
}
render_map :: proc(world: ^World) {
for y in 0 ..< MAP_H {
for x in 0 ..< MAP_W {
c := tile_color(world.world_map.tiles[y][x])
rl.DrawRectangle(i32(x * TILE_SIZE), i32(y * TILE_SIZE), TILE_SIZE, TILE_SIZE, c)
}
}
}