Added JSON reading to load levels
This commit is contained in:
parent
e7f2b46b17
commit
457239aac7
8 changed files with 10 additions and 3 deletions
|
@ -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())
|
||||
|
Before Width: | Height: | Size: 218 B After Width: | Height: | Size: 218 B |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 181 B After Width: | Height: | Size: 181 B |
1
Source/levels/level1.json
Normal file
1
Source/levels/level1.json
Normal 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
3
build.bat
Normal file
|
@ -0,0 +1,3 @@
|
|||
pdc Source "Rocket Bits.pdx"
|
||||
cd "Rocket Bits.pdx"
|
||||
main.pdz
|
Loading…
Reference in a new issue