aboutsummaryrefslogtreecommitdiff
path: root/src/tiled
diff options
context:
space:
mode:
Diffstat (limited to 'src/tiled')
-rw-r--r--src/tiled/tiled.odin26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/tiled/tiled.odin b/src/tiled/tiled.odin
index e01f6c5..373715a 100644
--- a/src/tiled/tiled.odin
+++ b/src/tiled/tiled.odin
@@ -138,7 +138,7 @@ Tile_Set :: struct {
tile_height: i32,
tile_offset: [2]i32, // in pixels
- tiles: []Tile,
+ tiles: []i32, // array of GIDs
}
Tile :: struct {
@@ -336,8 +336,8 @@ convert_json_map :: proc(jmap: Json_Map, tmap: ^Map, path: string) -> Error {
}
tmap.tile_sets[i] = tile_set
- for j in int(tile_set.first_gid)..<len(tmap.tiles) {
- tile_set.tiles[j].tile_set = i32(i)
+ for j in 0..<len(tmap.tiles) {
+ tmap.tiles[int(tile_set.first_gid) + j].tile_set = i32(i)
}
}
@@ -577,7 +577,7 @@ convert_json_tile_set :: proc(
tile_set.properties = convert_json_properties(jtile_set.properties)
- tile_set.tiles = make([]Tile, jtile_set.tilecount)
+ tile_set.tiles = make([]i32, jtile_set.tilecount)
// Ignore margin and spacing for now
// TODO: account for margin and spacing
@@ -587,7 +587,7 @@ convert_json_tile_set :: proc(
current_index := 0
for y in 0..<tile_y {
for x in 0..<tile_x {
- tile := &tile_set.tiles[current_index]
+ tile: Tile
tile.id = i32(current_index)
@@ -600,14 +600,24 @@ convert_json_tile_set :: proc(
tile_set.tile_height,
}
+ current_index += 1
+
tile.gid = i32(len(tmap.tiles))
- append(&tmap.tiles, tile^)
+ append(&tmap.tiles, tile)
- current_index += 1
+ tile_set.tiles[current_index - 1] = tile.gid
}
}
- // TODO: here, go through jtile_set.tiles and load in more tile data
+ for jtile in jtile_set.tiles {
+ ttile := &tmap.tiles[tile_set.tiles[jtile.id]]
+ object_group, err := convert_json_layer(jtile.objectgroup)
+ if err != .NONE {
+ return {}, err
+ }
+ ttile.object_group = object_group
+ ttile.properties = convert_json_properties(jtile.properties)
+ }
return tile_set, .NONE
}