Map parsing

This commit is contained in:
2026-08-21 19:48:16 +05:00
parent 01abef0b05
commit 8a7ca839fa
9 changed files with 426 additions and 53 deletions
+17 -5
View File
@@ -51,7 +51,8 @@ load_atlas :: proc() -> Atlas {
draw_tile :: proc(tile: Tile) {
offset := get_offset(tile.atlas, tile.frame)
offset, empty := get_offset(tile.atlas, tile.frame)
if empty do return
rl.DrawTexturePro(
tile.atlas^.tex,
rl.Rectangle {
@@ -73,13 +74,24 @@ draw_tile :: proc(tile: Tile) {
)
}
get_offset :: proc(atlas: ^Atlas, f: i32) -> rl.Vector2 {
get_offset :: proc(
atlas: ^Atlas,
f: i32,
) -> (
offset: rl.Vector2,
empty: bool,
) {
col := f % atlas.cols
row := f / atlas.cols
if f == 0 do return {}, true
return rl.Vector2 {
col := (f - 1) % atlas.cols
row := (f - 1) / atlas.cols
offset = rl.Vector2 {
f32(col) * atlas.tile_size.x,
f32(row) * atlas.tile_size.y,
}
return
}