From 457239aac75030520a4a8f7f27f5cd049a49c655 Mon Sep 17 00:00:00 2001 From: PossiblyAxolotl Date: Sun, 17 Apr 2022 14:39:37 -0600 Subject: [PATCH] Added JSON reading to load levels --- Main.lua => Source/Main.lua | 9 ++++++--- {gfx => Source/gfx}/font.fnt | 0 {gfx => Source/gfx}/rocket.png | Bin {gfx => Source/gfx}/testimg.png | Bin {gfx => Source/gfx}/tiles-table-16-16.png | Bin Source/levels/level1.json | 1 + {sfx => Source/sfx}/song1.wav | Bin build.bat | 3 +++ 8 files changed, 10 insertions(+), 3 deletions(-) rename Main.lua => Source/Main.lua (88%) rename {gfx => Source/gfx}/font.fnt (100%) rename {gfx => Source/gfx}/rocket.png (100%) rename {gfx => Source/gfx}/testimg.png (100%) rename {gfx => Source/gfx}/tiles-table-16-16.png (100%) create mode 100644 Source/levels/level1.json rename {sfx => Source/sfx}/song1.wav (100%) create mode 100644 build.bat diff --git a/Main.lua b/Source/Main.lua similarity index 88% rename from Main.lua rename to Source/Main.lua index 78b265f..f2d0afb 100644 --- a/Main.lua +++ b/Source/Main.lua @@ -17,8 +17,11 @@ local tilemap = 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()) diff --git a/gfx/font.fnt b/Source/gfx/font.fnt similarity index 100% rename from gfx/font.fnt rename to Source/gfx/font.fnt diff --git a/gfx/rocket.png b/Source/gfx/rocket.png similarity index 100% rename from gfx/rocket.png rename to Source/gfx/rocket.png diff --git a/gfx/testimg.png b/Source/gfx/testimg.png similarity index 100% rename from gfx/testimg.png rename to Source/gfx/testimg.png diff --git a/gfx/tiles-table-16-16.png b/Source/gfx/tiles-table-16-16.png similarity index 100% rename from gfx/tiles-table-16-16.png rename to Source/gfx/tiles-table-16-16.png diff --git a/Source/levels/level1.json b/Source/levels/level1.json new file mode 100644 index 0000000..2b6a313 --- /dev/null +++ b/Source/levels/level1.json @@ -0,0 +1 @@ +{"tiles":[{"x":1,"y":1,"t":2},{"x":2,"y":1,"t":3},{"x":3,"y":1,"t":2}]} \ No newline at end of file diff --git a/sfx/song1.wav b/Source/sfx/song1.wav similarity index 100% rename from sfx/song1.wav rename to Source/sfx/song1.wav diff --git a/build.bat b/build.bat new file mode 100644 index 0000000..5ab3412 --- /dev/null +++ b/build.bat @@ -0,0 +1,3 @@ +pdc Source "Rocket Bits.pdx" +cd "Rocket Bits.pdx" +main.pdz \ No newline at end of file