Чтение параметров тайлсета из tiles.json
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user