Added JSON reading to load levels

This commit is contained in:
PossiblyAxolotl 2022-04-17 14:39:37 -06:00
parent e7f2b46b17
commit 457239aac7
8 changed files with 10 additions and 3 deletions

View file

@ -17,8 +17,11 @@ local tilemap <const> = gfx.tilemap.new()
tilemap:setImageTable(tileTable)
tilemap:setSize(16,16)
tilemap:setTileAtPosition(2, 2, 2)
tilemap:setTileAtPosition(2, 10, 2)
local level = json.decodeFile("levels/level1.json")
for i = 1, #level.tiles, 1 do
tilemap:setTileAtPosition(level.tiles[i].x,level.tiles[i].y,level.tiles[i].t)
end
gfx.sprite.addWallSprites(tilemap, {0,1})
@ -52,7 +55,7 @@ function playdate.update()
sprRocket:setRotation(0)
sprRocket:update()
print(#sprRocket:overlappingSprites())
--print(#sprRocket:overlappingSprites())
sprRocket:setRotation(playdate.getCrankPosition())

View file

Before

Width:  |  Height:  |  Size: 218 B

After

Width:  |  Height:  |  Size: 218 B

View file

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View file

Before

Width:  |  Height:  |  Size: 181 B

After

Width:  |  Height:  |  Size: 181 B

View file

@ -0,0 +1 @@
{"tiles":[{"x":1,"y":1,"t":2},{"x":2,"y":1,"t":3},{"x":3,"y":1,"t":2}]}

3
build.bat Normal file
View file

@ -0,0 +1,3 @@
pdc Source "Rocket Bits.pdx"
cd "Rocket Bits.pdx"
main.pdz