Skip to content

Commit

Permalink
basic tiled map loading/rendering, issue #36
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Ji committed Nov 16, 2024
1 parent 8390148 commit 0544cf2
Show file tree
Hide file tree
Showing 4 changed files with 379 additions and 60 deletions.
2 changes: 1 addition & 1 deletion build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.{
.name = "jok",
.version = "0.18.4",
.version = "0.19.0",
.paths = .{
"README.md",
"build.zig",
Expand Down
178 changes: 151 additions & 27 deletions examples/assets/tiled/sample_urban.tmx
Original file line number Diff line number Diff line change
@@ -1,38 +1,162 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.8" tiledversion="1.8.2" orientation="orthogonal" renderorder="right-down" width="48" height="24" tilewidth="16" tileheight="16" infinite="0" nextlayerid="5" nextobjectid="1">
<map version="1.8" tiledversion="1.8.2" orientation="orthogonal" renderorder="right-down" width="48" height="32" tilewidth="16" tileheight="16" infinite="1" backgroundcolor="#77767b" nextlayerid="6" nextobjectid="1">
<properties>
<property name="fancycolor" type="color" value="#ff33d17a"/>
</properties>
<tileset firstgid="1" source="tileset_colored.tsx"/>
<group id="3" name="group1">
<layer id="5" name="Layer 2" width="48" height="32" tintcolor="#f6d32d" offsetx="16" offsety="16">
<data encoding="csv">
<chunk x="-16" y="16" width="16" height="16">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,513,514,515,0,
0,0,0,0,0,0,0,0,0,0,0,0,545,546,547,0,
0,0,0,0,0,0,0,0,0,0,0,0,577,578,579,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</chunk>
<chunk x="0" y="16" width="16" height="16">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
513,514,515,513,514,515,513,514,515,0,0,0,0,0,0,0,
545,546,547,545,546,547,545,546,547,0,0,0,0,0,0,0,
577,578,579,577,578,579,577,578,579,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</chunk>
</data>
</layer>
<group id="4" name="group2">
<layer id="2" name="Tile Layer 1" width="48" height="24">
<layer id="2" name="Tile Layer 1" width="48" height="32">
<data encoding="csv">
6,6,6,358,358,358,358,2,1,161,1,488,488,488,1,1,1,1,1,17,73,17,593,594,595,1,68,68,6,2,6,1610612907,1610612906,1610612906,169,169,169,169,169,3221225642,1,2147483716,2147483649,2147484243,2147484242,2147484241,2147483665,2147483721,
1,1,1,488,328,328,488,1,1,161,1,422,328,422,2,2,2,2,33,17,73,17,556,556,556,68,2,6,33,68,68,68,2,2,1610612907,1610612906,1610612906,1610612906,1610612906,3221225643,1,2147483650,2147483716,2147484204,2147484204,2147484204,2147483665,2147483721,
17,17,17,17,3221225486,14,17,17,17,107,17,17,17,17,17,17,33,6,33,17,73,17,556,556,556,1,1,1,68,1,1,1,6,1,1,2147483654,2147483649,2147483649,2147483649,2147483716,2147483649,2147483649,2147483649,2147484204,2147484204,2147484204,2147483665,2147483721,
1610612750,1610612750,1610612750,1610612750,1,1,1610612750,1610612750,1610612750,107,1610612750,1610612750,1610612750,1610612750,1610612752,17,1,33,1,17,73,17,555,326,555,130,130,130,130,130,130,130,130,130,2147483778,2147483778,2147483778,2147483778,2147483778,2147483778,2147483778,2147483778,2147483778,2147484203,2147483974,2147484203,2147483665,2147483721,
2684354606,2684354606,2684354606,2684354606,2684354606,2684354606,2684354606,2684354606,2684354606,107,2684354606,1610612782,1610612782,3221225519,14,17,529,530,531,17,73,17,17,17,17,17,17,17,17,17,17,17,17,17,2147483665,2147483665,2147483665,2147483665,2147483665,2147483665,2147483665,2147483665,2147483665,2147483665,2147483665,2147483665,2147483665,2147483721,
2684354574,2684354574,2684354574,2684354574,2684354574,2684354574,2684354574,2684354574,2684354574,107,2684354574,2684354574,1,46,14,17,561,1,563,17,73,17,398,1,1,1,529,530,530,531,1,1,1,1,130,130,130,130,2147484179,2147484178,2147484178,2147484177,2147483649,2147483649,2147483649,2147484046,2147483665,2147483721,
17,17,427,427,427,427,427,427,17,107,17,17,3221225486,46,15,17,593,594,595,17,73,17,1,529,530,531,561,1,1,563,1,1,33,1,130,70,2147483649,2147483649,2147484211,2147483649,2147483649,2147484209,2147484179,2147484178,2147484177,2147483649,2147483665,2147483721,
1,1,1,428,1,399,1,397,1,161,1,17,751,46,14,17,587,556,587,17,73,17,1,561,1,563,488,625,626,626,626,627,1,1,529,530,530,530,530,530,531,2147484136,2147484211,2147483649,2147484209,2147483649,2147483665,2147483721,
1,1,1,428,1,3,1,429,3,161,33,17,3221225486,46,14,17,587,556,587,17,73,17,1,593,594,595,488,657,1,1,1,659,1,68,561,1,1,1,1,1,563,2147484136,2147484243,2147484242,2147484241,2147483649,2147483665,2147483721,
1,1,462,462,462,1,3,1,1,161,1,17,3221225486,46,14,17,587,556,587,17,73,17,1,556,556,556,1,689,690,690,690,691,68,1,593,594,594,594,594,594,595,2147483649,2147484204,2147484204,2147484204,2147483649,2147483665,2147483721,
1,1,432,432,432,1,393,394,2147484041,161,401,17,3221225486,46,719,17,587,556,587,17,73,17,430,556,556,556,1,488,424,488,424,488,1,1,555,555,555,555,555,555,555,2147483649,2147484204,2147484204,2147484204,2147484078,2147483665,2147483721,
1,1,1,1,1,1,1,3,3,161,68,17,3221225486,46,14,17,587,328,587,17,73,17,130,555,326,555,1,488,424,362,424,488,1,1,555,331,2147483979,555,331,2147483979,555,2147483649,2147484203,2147483974,2147484203,2147483778,2147483665,2147483721,
99,99,99,99,99,99,99,99,99,161,99,17,367,46,719,17,398,17,1,17,73,17,1,35,17,35,1,6,6,17,6,6,1,1,2147483649,3221225486,14,2147483649,3221225486,14,2147483649,2147483649,2147483683,2147483665,2147483683,2147483649,2147483665,2147483721,
17,17,17,17,17,17,17,17,17,107,17,17,3221225486,46,14,17,17,17,17,17,73,17,17,17,17,17,17,17,17,17,17,2147483665,2147483665,2147483665,2147483665,3221225486,14,2147483665,3221225486,14,2147483665,2147483665,2147483665,2147483665,2147483665,2147483665,2147483665,2147483721,
1610612750,1610612750,1610612750,1610612750,1610612750,1610612750,1610612750,1610612750,1610612750,107,750,1610612750,1,46,1,1610612751,1610612750,1610612750,1610612750,1610612750,1,1610612750,716,1610612750,716,1610612750,1610612751,653,654,1610612750,1610612750,3758096398,3758096398,3758096398,3758096398,1,1,3758096398,1,653,654,3758096399,3758096398,716,3758096398,716,3758096398,2147483649,
2684354606,2684354606,2684354606,2684354606,2684354606,2684354606,3221225520,2684354606,2684354606,107,2684354606,2684354606,2684354606,48,2684354606,2684354606,2684354606,2684354606,2684354606,2684354606,2684354606,2684354606,2684354606,2684354606,2684354606,2684354606,2684354606,2684354606,1610612782,1610612782,536870958,536870958,536870958,536870958,536870958,536870958,536870958,536870958,3758096430,3758096430,536870958,536870958,536870958,536870958,536870958,536870958,536870958,536870958,
2684354574,2684354574,2684354574,2684354574,2684354574,1,46,1,2684354574,107,2684354574,2684354574,2684354574,2147484270,2147484269,2684354574,2684354574,1,2684354574,2147484302,2147484301,2684354574,2147484398,2684354574,2684354574,2684354574,2684354574,2684354574,2684354574,1,46,2147483649,536870926,536870926,536870926,536870926,2147483649,2147483694,2147483649,536870926,536870926,536870926,536870926,536870926,536870926,2147484398,536870926,2147484302,
17,17,17,17,17,3221225486,46,14,17,107,17,17,17,17,17,17,17,73,17,17,17,17,17,17,17,17,17,17,17,3221225486,46,14,2147483665,2147483665,2147483665,2147483665,2147483662,2147483694,1073741838,2147483665,2147483665,2147483665,2147483665,2147483665,2147483665,2147483665,2147483665,2147483665,
33,2,68,1,17,3221225486,46,14,17,161,1,1,1,1,1,1,17,73,17,1,1,1,1,398,1,1,1,1,17,3221225677,3221225677,3221225677,17,130,130,2147483665,1073742029,1073742029,1073742029,2147483665,2147483649,2147483649,2147483649,2147483649,2147484046,2147483649,2147483649,2147483649,
6,68,68,1,17,3221225486,46,14,17,161,625,626,626,626,627,1,17,73,17,1,529,530,531,1,68,2,1,2,17,3221225486,46,751,17,1,2147483649,2147483665,2147483662,2147483694,1073741838,2147483665,2147483650,2147483649,2147483650,2147483716,2147483649,2147484179,2147484178,2147484177,
2684354730,2684354731,2,68,17,3221225486,46,14,17,161,657,1,1,1,659,1,17,73,17,1,561,1,563,1,1,68,6,1,17,719,46,14,17,360,360,2147483665,2147483662,2147483694,1073741838,2147483665,2147483649,2147483654,2147483716,2147483649,2147483649,2147484211,2147483649,2147484209,
169,3221225642,2,68,17,3221225486,46,14,17,161,689,690,690,690,691,130,17,73,17,130,593,594,595,530,530,530,531,1,17,3221225486,46,14,17,326,555,2147483665,2147483662,2147483694,1073741838,2147483665,2147483649,2147484179,2147484178,2147484178,2147484178,2147484243,2147484242,2147484241,
169,169,2684354731,33,17,3221225486,46,14,17,161,488,424,488,424,488,1,17,73,17,1,556,556,556,1,1,1,563,1,17,719,46,15,17,2147483665,2147483665,2147483665,2147483663,2147483694,1073741838,2147483665,2147483649,2147484211,2147483649,2147483649,2147483649,2147484204,2147484204,2147484204,
169,169,3221225642,1,17,3221225486,46,14,17,161,488,424,488,424,488,1,17,73,17,1,556,556,556,594,594,594,595,1,17,3221225486,46,14,17,2147483665,2147483665,2147483665,2147483662,2147483694,1073741838,2147483665,2147483649,2147484243,2147484242,2147484242,2147484242,2147484204,2147484204,2147484204
</data>
<chunk x="0" y="0" width="16" height="16">
6,6,6,358,358,358,358,2,1,161,1,488,488,488,1,1,
1,1,1,488,328,328,488,1,1,161,1,422,328,422,2,2,
17,17,17,17,3221225486,14,17,17,17,107,17,17,17,17,17,17,
1610612750,1610612750,1610612750,1610612750,1,1,1610612750,1610612750,1610612750,107,1610612750,1610612750,1610612750,1610612750,1610612752,17,
2684354606,2684354606,2684354606,2684354606,2684354606,2684354606,2684354606,2684354606,2684354606,107,2684354606,1610612782,1610612782,3221225519,14,17,
2684354574,2684354574,2684354574,2684354574,2684354574,2684354574,2684354574,2684354574,2684354574,107,2684354574,2684354574,1,46,14,17,
17,17,427,427,427,427,427,427,17,107,17,17,3221225486,46,15,17,
1,1,1,428,1,399,1,397,1,161,1,17,751,46,14,17,
1,1,1,428,1,3,1,429,3,161,33,17,3221225486,46,14,17,
1,1,462,462,462,1,3,1,1,161,1,17,3221225486,46,14,17,
1,1,432,432,432,1,393,394,2147484041,161,401,17,3221225486,46,719,17,
1,1,1,1,1,1,1,3,3,161,68,17,3221225486,46,14,17,
99,99,99,99,99,99,99,99,99,161,99,17,367,46,719,17,
17,17,17,17,17,17,17,17,17,107,17,17,3221225486,46,14,17,
1610612750,1610612750,1610612750,1610612750,1610612750,1610612750,1610612750,1610612750,1610612750,107,750,1610612750,1,46,1,1610612751,
2684354606,2684354606,2684354606,2684354606,2684354606,2684354606,3221225520,2684354606,2684354606,107,2684354606,2684354606,2684354606,48,2684354606,2684354606
</chunk>
<chunk x="16" y="0" width="16" height="16">
1,1,1,17,73,17,593,594,595,1,68,68,6,2,6,1610612907,
2,2,33,17,73,17,556,556,556,68,2,6,33,68,68,68,
33,6,33,17,73,17,556,556,556,1,1,1,68,1,1,1,
1,33,1,17,73,17,555,326,555,130,130,130,130,130,130,130,
529,530,531,17,73,17,17,17,17,17,17,17,17,17,17,17,
561,1,563,17,73,17,398,1,1,1,529,530,530,531,1,1,
593,594,595,17,73,17,1,529,530,531,561,1,1,563,1,1,
0,556,0,17,73,17,1,561,1,563,488,625,626,626,626,627,
0,556,0,17,73,17,1,593,594,595,488,657,1,1,1,659,
0,556,0,17,73,17,1,556,556,556,1,689,690,690,690,691,
0,556,0,17,73,17,430,556,556,556,1,488,424,488,424,488,
0,328,0,17,73,17,130,555,326,555,1,488,424,362,424,488,
398,17,1,17,73,17,1,35,17,35,1,6,6,17,6,6,
17,17,17,17,73,17,17,17,17,17,17,17,17,17,17,2147483665,
1610612750,1610612750,1610612750,1610612750,1,1610612750,716,1610612750,716,1610612750,1610612751,653,654,1610612750,1610612750,3758096398,
2684354606,2684354606,2684354606,2684354606,2684354606,2684354606,2684354606,2684354606,2684354606,2684354606,2684354606,2684354606,1610612782,1610612782,536870958,536870958
</chunk>
<chunk x="32" y="0" width="16" height="16">
1610612906,1610612906,169,169,169,169,169,3221225642,1,2147483716,2147483649,2147484243,2147484242,2147484241,2147483665,2147483721,
2,2,1610612907,1610612906,1610612906,1610612906,1610612906,3221225643,1,2147483650,2147483716,0,2147484204,0,2147483665,2147483721,
6,1,1,2147483654,2147483649,2147483649,2147483649,2147483716,2147483649,2147483649,2147483649,0,2147484204,0,2147483665,2147483721,
130,130,2147483778,2147483778,2147483778,2147483778,2147483778,2147483778,2147483778,2147483778,2147483778,0,2147483974,0,2147483665,2147483721,
17,17,2147483665,2147483665,2147483665,2147483665,2147483665,2147483665,2147483665,2147483665,2147483665,2147483665,2147483665,2147483665,2147483665,2147483721,
1,1,130,130,130,130,2147484179,2147484178,2147484178,2147484177,2147483649,2147483649,2147483649,2147484046,2147483665,2147483721,
33,1,130,70,2147483649,2147483649,2147484211,2147483649,2147483649,2147484209,2147484179,2147484178,2147484177,2147483649,2147483665,2147483721,
1,1,529,530,530,530,530,530,531,2147484136,2147484211,2147483649,2147484209,2147483649,2147483665,2147483721,
1,68,561,1,1,1,1,1,563,2147484136,2147484243,2147484242,2147484241,2147483649,2147483665,2147483721,
68,1,593,594,594,594,594,594,595,2147483649,0,2147484204,0,2147483649,2147483665,2147483721,
1,1,555,555,555,555,555,555,555,2147483649,0,2147484204,0,2147484078,2147483665,2147483721,
1,1,555,331,2147483979,555,331,2147483979,555,2147483649,0,2147483974,0,2147483778,2147483665,2147483721,
1,1,2147483649,3221225486,14,2147483649,3221225486,14,2147483649,2147483649,2147483683,2147483665,2147483683,2147483649,2147483665,2147483721,
2147483665,2147483665,2147483665,3221225486,14,2147483665,3221225486,14,2147483665,2147483665,2147483665,2147483665,2147483665,2147483665,2147483665,2147483721,
3758096398,3758096398,3758096398,1,1,3758096398,1,653,654,3758096399,3758096398,716,3758096398,716,3758096398,2147483649,
536870958,536870958,536870958,536870958,536870958,536870958,3758096430,3758096430,536870958,536870958,536870958,536870958,536870958,536870958,536870958,536870958
</chunk>
<chunk x="0" y="16" width="16" height="16">
2684354574,2684354574,2684354574,2684354574,2684354574,1,46,1,2684354574,107,2684354574,2684354574,2684354574,2147484270,2147484269,2684354574,
17,17,17,17,17,3221225486,46,14,17,107,17,17,17,17,17,17,
33,2,68,1,17,3221225486,46,14,17,161,1,1,1,1,1,1,
6,68,68,1,17,3221225486,46,14,17,161,625,626,626,626,627,1,
2684354730,2684354731,2,68,17,3221225486,46,14,17,161,657,1,1,1,659,1,
169,3221225642,2,68,17,3221225486,46,14,17,161,689,690,690,690,691,130,
169,169,2684354731,33,17,3221225486,46,14,17,161,488,424,488,424,488,1,
169,169,3221225642,1,17,3221225486,46,14,17,161,488,424,488,424,488,1,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</chunk>
<chunk x="16" y="16" width="16" height="16">
2684354574,1,2684354574,2147484302,2147484301,2684354574,2147484398,2684354574,2684354574,2684354574,2684354574,2684354574,2684354574,1,46,2147483649,
17,73,17,17,17,17,17,17,17,17,17,17,17,3221225486,46,14,
17,73,17,1,1,1,1,398,1,1,1,1,17,3221225677,3221225677,3221225677,
17,73,17,1,529,530,531,1,68,2,1,2,17,3221225486,46,751,
17,73,17,1,561,1,563,1,1,68,6,1,17,719,46,14,
17,73,17,130,593,594,595,530,530,530,531,1,17,3221225486,46,14,
17,73,17,1,556,556,556,1,1,1,563,1,17,719,46,15,
17,73,17,1,556,556,556,594,594,594,595,1,17,3221225486,46,14,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,372,372,372,372,372,372,0,0,0,0,0,0,
0,0,0,0,372,971,971,971,971,372,0,0,0,0,0,0,
0,0,0,0,372,971,971,971,971,372,0,0,0,0,0,0,
0,0,0,0,372,372,372,372,372,372,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</chunk>
<chunk x="32" y="16" width="16" height="16">
536870926,536870926,536870926,536870926,2147483649,2147483694,2147483649,536870926,536870926,536870926,536870926,536870926,536870926,2147484398,536870926,2147484302,
2147483665,2147483665,2147483665,2147483665,2147483662,2147483694,1073741838,2147483665,2147483665,2147483665,2147483665,2147483665,2147483665,2147483665,2147483665,2147483665,
17,130,130,2147483665,1073742029,1073742029,1073742029,2147483665,2147483649,2147483649,2147483649,2147483649,2147484046,2147483649,2147483649,2147483649,
17,1,2147483649,2147483665,2147483662,2147483694,1073741838,2147483665,2147483650,2147483649,2147483650,2147483716,2147483649,2147484179,2147484178,2147484177,
17,360,360,2147483665,2147483662,2147483694,1073741838,2147483665,2147483649,2147483654,2147483716,2147483649,2147483649,2147484211,2147483649,2147484209,
17,326,555,2147483665,2147483662,2147483694,1073741838,2147483665,2147483649,2147484179,2147484178,2147484178,2147484178,2147484243,2147484242,2147484241,
17,2147483665,2147483665,2147483665,2147483663,2147483694,1073741838,2147483665,2147483649,2147484211,2147483649,2147483649,2147483649,2147484204,2147484204,2147484204,
17,2147483665,2147483665,2147483665,2147483662,2147483694,1073741838,2147483665,2147483649,2147484243,2147484242,2147484242,2147484242,2147484204,2147484204,2147484204,
0,0,0,0,0,0,0,0,0,0,397,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,397,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,397,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,397,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,397,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,397,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,429,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,431,0,0,0,0,0
</chunk>
</data>
</layer>
</group>
</group>
Expand Down
17 changes: 13 additions & 4 deletions examples/tiled.zig
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
const std = @import("std");
const jok = @import("jok");
const physfs = jok.physfs;
const j2d = jok.j2d;
const tiled = jok.utils.tiled;

var batchpool: j2d.BatchPool(64, false) = undefined;
var map: tiled.TiledMap = undefined;

pub fn init(ctx: jok.Context) !void {
// your init code

try physfs.mount("assets", "", true);

const loaded = try tiled.loadTMX(ctx, "tiled/sample_urban.tmx");
defer loaded.deinit();
batchpool = try @TypeOf(batchpool).init(ctx);
map = try tiled.loadTMX(ctx, "tiled/sample_urban.tmx");
}

pub fn event(ctx: jok.Context, e: jok.Event) !void {
Expand All @@ -24,11 +28,16 @@ pub fn update(ctx: jok.Context) !void {
}

pub fn draw(ctx: jok.Context) !void {
// your drawing code
_ = ctx;
try ctx.renderer().clear(map.bgcolor);

var b = try batchpool.new(.{});
defer b.submit();
try map.render(b);
}

pub fn quit(ctx: jok.Context) void {
// your deinit code
_ = ctx;
map.deinit();
batchpool.deinit();
}
Loading

0 comments on commit 0544cf2

Please sign in to comment.