remove function, make tile_colors a table
This commit is contained in:
+5
-12
@@ -11,17 +11,10 @@ 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
|
||||
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) {
|
||||
@@ -57,7 +50,7 @@ can_build_at :: proc(world_map: ^Map, gx, gy: int) -> bool {
|
||||
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])
|
||||
c := TILE_COLORS[world.world_map.tiles[y][x]]
|
||||
rl.DrawRectangle(i32(x * TILE_SIZE), i32(y * TILE_SIZE), TILE_SIZE, TILE_SIZE, c)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user