55 lines
998 B
Odin
55 lines
998 B
Odin
package game
|
|
|
|
import rl "vendor:raylib"
|
|
import "core:fmt"
|
|
|
|
|
|
CELL_SIZE :: 16
|
|
WORLD_SIZE :: 10
|
|
|
|
World :: struct {
|
|
grid: [WORLD_SIZE][WORLD_SIZE]Tile
|
|
}
|
|
|
|
Tile :: struct {
|
|
type: TileType,
|
|
tilemap_pos:rl.Vector2,
|
|
color:rl.Color,
|
|
}
|
|
|
|
TileType :: enum {
|
|
NOTHING,
|
|
WALL,
|
|
DOOR,
|
|
FLOOR,
|
|
}
|
|
|
|
set_grid_tile :: proc(w:^World, pos:Vec2i, t:Tile) {
|
|
w.grid[pos.x][pos.y] = t
|
|
}
|
|
|
|
fill_world_grid_with_nothing :: proc(w:^World) {
|
|
for x in 0..< len(w.grid) {
|
|
for y in 0..<len(w.grid) {
|
|
w.grid[x][y] = Tile {
|
|
type = .NOTHING,
|
|
tilemap_pos = {0,0}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
draw_world :: proc(w:^World) {
|
|
for x in 0..< len(w.grid) {
|
|
for y in 0..< len(w.grid) {
|
|
tile := w.grid[x][y]
|
|
posX := x * TILE_SIZE
|
|
posY := y * TILE_SIZE
|
|
|
|
if tile.type != .NOTHING {
|
|
draw_tile(tile.tilemap_pos, {f32(posX), f32(posY)}, tile.color)
|
|
}
|
|
}
|
|
}
|
|
}
|