Чтение параметров тайлсета из tiles.json

This commit is contained in:
2026-08-28 18:42:24 +05:00
parent 297d03632d
commit 9627da093e
3 changed files with 80 additions and 2 deletions
+10 -2
View File
@@ -1,6 +1,8 @@
package main
import "core:fmt"
import os "core:os"
import "core:strings"
import rl "vendor:raylib"
@@ -23,8 +25,14 @@ Tile :: struct {
load_atlas :: proc() -> Atlas {
at: Atlas
at.tex = rl.LoadTexture("./assets/3rdparty/tileset/Tiles/Tileset.png")
at.tile_size = rl.Vector2{16, 16}
ts, err := load_tileset("./Tiled/tiles.json", context.allocator)
if err.type != .None {
fmt.println(err.msg)
os.exit(1)
}
at.tex = rl.LoadTexture(strings.clone_to_cstring(ts.texture_path))
at.tile_size = rl.Vector2{f32(ts.tile_width), f32(ts.tile_height)}
at.rows = at.tex.height / (i32(at.tile_size.y))
at.cols = at.tex.width / i32(at.tile_size.x)
at.frames = at.cols * at.rows