59 lines
1.0 KiB
Odin
59 lines
1.0 KiB
Odin
package game
|
|
|
|
import rl "vendor:raylib"
|
|
Tile_Kind :: enum {
|
|
Blocked,
|
|
Path,
|
|
Build,
|
|
}
|
|
|
|
Map :: struct {
|
|
tiles: [MAP_H][MAP_W]Tile_Kind,
|
|
}
|
|
|
|
TILE_COLORS: [Tile_Kind]rl.Color = {
|
|
.Blocked = {35, 95, 35, 255},
|
|
.Path = {130, 85, 45, 255},
|
|
.Build = {50, 130, 50, 255},
|
|
}
|
|
|
|
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_COLORS[world.world_map.tiles[y][x]]
|
|
rl.DrawRectangle(i32(x * TILE_SIZE), i32(y * TILE_SIZE), TILE_SIZE, TILE_SIZE, c)
|
|
}
|
|
}
|
|
}
|
|
|