diff --git a/Source/Editor.lua b/Source/Editor.lua index 9407ae3..7d1f15c 100644 --- a/Source/Editor.lua +++ b/Source/Editor.lua @@ -5,19 +5,39 @@ local gfx = playdate.graphics local prevtext = "" gfx.setLineWidth(5) +local tileTable = gfx.imagetable.new("gfx/tiles") +local tilemapEditor = gfx.tilemap.new() +tilemapEditor:setImageTable(tileTable) +local tiles = {} + +tilemapEditor:setSize(10,10) +local imgtiles = gfx.sprite.new(tilemapEditor) +local w, h = imgtiles:getSize() +imgtiles:moveTo(w/2,h/2) + local position = {x=0,y=0} +local positionLerp = {x=0,y=0} local bool2int = {[true]=1,[false]=0} +local menu = playdate.getSystemMenu() +local toolTipButton, error + +local editor = "main" local imgSwitch = gfx.imagetable.new("gfx/switch") local imgFloppy = gfx.image.new("gfx/floppy") +local imgAdd = gfx.image.new("gfx/add") +local imgMus = gfx.image.new("gfx/music") +local imgLine = gfx.image.new("gfx/line") +local imgSpin = gfx.image.new("gfx/spin") +local imgCursor = gfx.image.new("gfx/cursor2") assert(imgSwitch) assert(imgFloppy) -local sprSwitch = gfx.sprite.new(imgSwitch:getImage(1)) -local sprFloppy = gfx.sprite.new(imgFloppy) - -sprSwitch:moveTo(381,47) -sprFloppy:moveTo(381,17) +assert(imgAdd) +assert(imgMus) +assert(imgLine) +assert(imgSpin) +assert(imgCursor) function newProject() mode = "newproj" @@ -37,9 +57,11 @@ function playdate.keyboard.keyboardWillHideCallback(ok) editLoad() else mode = "editor" - sprSwitch:add() - sprFloppy:add() - + toolTipButton, error = menu:addCheckmarkMenuItem("show help",true, function(value) + print(value) + end) + imgtiles:add() + menuButton:setTitle("save & quit") playdate.wait(0.1) end end @@ -56,7 +78,7 @@ end local tileIndex = 0.0 -local curY = math.floor( tileIndex ) * 30 + 2 +local curY = math.floor( tileIndex ) * 28 + 3 local curYlerp = -32 function editUpdate() @@ -65,14 +87,24 @@ function editUpdate() tileIndex += change * 0.01 - curY = math.floor( tileIndex ) * 30 + 2 + if tileIndex > 7.9 then tileIndex = 0 end + if tileIndex < 0 then tileIndex = 7.9 end - curYlerp = playdate.math.lerp(curYlerp, curY, 0.3) + curY = math.floor( tileIndex ) * 28 +7 + + curYlerp = playdate.math.lerp(curYlerp, curY, 0.4) + positionLerp.x = playdate.math.lerp(positionLerp.x, position.x * 16, 0.5) + positionLerp.y = playdate.math.lerp(positionLerp.y, position.y * 16, 0.5) if playdate.buttonJustPressed(playdate.kButtonA) then if math.floor( tileIndex ) == 1 then playdate.display.setInverted(not playdate.display.getInverted()) - sprSwitch:setImage(imgSwitch:getImage(bool2int[playdate.display.getInverted()] + 1)) + elseif math.floor( tileIndex ) == 3 then + tilemapEditor:setTileAtPosition(position.x+12,position.y+8,2) + tiles[#tiles+1] = {x=position.x + 12, y=position.y + 8, 2} + imgtiles = gfx.sprite.new(tilemapEditor) + w, h = imgtiles:getSize() + imgtiles:moveTo(w/2,h/2) end end @@ -81,22 +113,46 @@ function editUpdate() elseif playdate.buttonJustPressed(playdate.kButtonRight) then position.x += 1 end + if playdate.buttonJustPressed(playdate.kButtonUp) then + position.y -= 1 + elseif playdate.buttonJustPressed(playdate.kButtonDown) then + position.y += 1 + end + + gfx.clear() -- draw map - gfx.setDrawOffset(position.x*16,position.y*16) + gfx.setDrawOffset(-positionLerp.x, -positionLerp.y) + imgtiles:update() + imgCursor:draw((position.x + 11) * 16, (position.y + 7) * 16) - -- draw ui + -- draw ui/ gfx.setDrawOffset(0,0) - gfx.sprite.update() + gfx.setColor(gfx.kColorBlack) + gfx.fillRect(365,0,400,240) gfx.setColor(gfx.kColorWhite) gfx.drawLine(360,0,360,240) + -- draw changes + if editor == "main" then + imgMus:draw(366, 64) + imgAdd:draw(366,93) + imgSwitch:getImage(bool2int[playdate.display.getInverted()] + 1):draw(366,36) + imgFloppy:draw(366,8) + imgLine:draw(366,120) + imgSpin:draw(366,148) + end + gfx.setColor(playdate.graphics.kColorXOR) - gfx.fillRect(365,curYlerp,33,30) + gfx.fillRect(365,curYlerp,33,28) end function editClose() - sprSwitch:remove() - sprFloppy:remove() + for tile = 1, #tiles, 1 do + tilemapEditor:setTileAtPosition(tiles[tile].x,tiles[tile].y,0) + end + imgtiles:remove() + playdate.getSystemMenu():removeMenuItem(toolTipButton) + menuButton:setTitle("game menu") end \ No newline at end of file diff --git a/Source/Main.lua b/Source/Main.lua index bb6ad2c..8e27a55 100644 --- a/Source/Main.lua +++ b/Source/Main.lua @@ -48,6 +48,8 @@ createMenu(mainmenu) local menu = playdate.getSystemMenu() menuButton, error = menu:addMenuItem("game menu", function() if mode == "game" then + removeMap() + playdate.datastore.delete("savegame.json") playdate.datastore.write({savedLevel=map,savedDeaths=deaths},"savegame") elseif mode == "editor" then editClose() @@ -100,7 +102,7 @@ function playdate.update() gfx.clear() updateNewproj() elseif mode == "editor" then - gfx.clear() + editUpdate() if playdate.isCrankDocked() then @@ -117,6 +119,7 @@ end function playdate.gameWillTerminate() if mode == "game" then + playdate.datastore.delete("savegame.json") playdate.datastore.write({savedLevel=map,savedDeaths=deaths},"savegame") end end \ No newline at end of file diff --git a/Source/Map.lua b/Source/Map.lua index 44379b7..232a899 100644 --- a/Source/Map.lua +++ b/Source/Map.lua @@ -35,6 +35,15 @@ function addMap(_file, rs) tilemap:setTileAtPosition(level.tiles[i].x,level.tiles[i].y,level.tiles[i].t) end + song:stop() + if level.song then + song:load("sfx/"..level.song) + else + song:load("sfx/song2") + end + + song:play(0) + if level.inverted then playdate.display.setInverted(true) else playdate.display.setInverted(false) end if level.saws then loadBlades(level.saws) end if level.rotators then loadSpins(level.rotators) end @@ -50,3 +59,12 @@ function addMap(_file, rs) sprTiles:moveTo(sprTiles.width/2,sprTiles.height/2) sprTiles:add() end + +function removeMap() + if #tiles > 0 then + for i = 1, #tiles, 1 do + tiles[i]:remove() + end + end + sprTiles:remove() +end \ No newline at end of file diff --git a/Source/Menu.lua b/Source/Menu.lua index d070562..f104bcc 100644 --- a/Source/Menu.lua +++ b/Source/Menu.lua @@ -27,9 +27,11 @@ function mainMenuCreation() mainmenu = {} mainmenu[4],mainmenu[3],mainmenu[2], mainmenu[1], mainmenu[0] = "START NEW GAME", "USER LEVELS", "LEVEL EDITOR", "EXTRAS", "mainNoPlay" - if playdate.datastore.read("savegame") then - map = playdate.datastore.read("savegame").savedLevel - deaths = playdate.datastore.read("savegame").savedDeaths + local g = playdate.datastore.read("savegame") + + if g then + map = g.savedLevel + deaths = g.savedDeaths mainmenu[5], mainmenu[0] = "CONTINUE", "mainPlay" end end @@ -108,12 +110,35 @@ function updateMenu() end end +local function dataLoad() + barpos = 160 + logopos = -112 + local lvls = playdate.file.listFiles("data") + local m = {} + m[0], m[1] = "data", "EXTRAS" + if #lvls - ((10*page)) <= 0 then page = 0 end + if #lvls <= 11 then + for i = 1, #lvls, 1 do + m[i+1] = lvls[i]:upper() + end + elseif lvls[1 + (10*page)] then + m[2] = "NEXT PAGE" + for i = 1, 10, 1 do + if lvls[i+(10*page)] then + m[i+2] = lvls[i+(10*page)]:upper() + end + end + end + + createMenu(m) +end + local function customLoad() barpos = 160 logopos = -112 local lvls = playdate.file.listFiles("levels") local m = {} - m[0], m[1] = "customs", "BACK" + m[0], m[1] = "customs", "MENU" if #lvls - ((10*page)) <= 0 then page = 0 end if #lvls <= 11 then for i = 1, #lvls, 1 do @@ -136,7 +161,7 @@ function editLoad() barpos = 160 local lvls = playdate.file.listFiles("levels") local m = {} - m[0], m[1], m[2] = "edits", "BACK", "CREATE NEW" + m[0], m[1], m[2] = "edits", "MENU", "CREATE NEW" if #lvls - (1 + (9*page)) <= 0 then page = 0 end if #lvls <= 10 then for i = 1, #lvls, 1 do @@ -175,7 +200,7 @@ function menuButtonPress(name) local m = {} --barpos = 160 --logopos = -112 - m[0],m[1], m[2], m[3], m[4], m[5] = "extras", "BACK", "MUSIC BOX", "END CUTSCENE", "START CUTSCENE", "LEVEL SELECT" + m[0],m[1], m[2], m[3], m[4], m[5] = "extras", "MENU", "MUSIC BOX", "END CUTSCENE", "START CUTSCENE", "LEVEL SELECT" if playdate.file.exists("bonusLevels.rocketbytes") then m[6] = "EXTRA LEVELS" end @@ -187,6 +212,8 @@ function menuButtonPress(name) elseif name == "LEVEL EDITOR" then page = 0 editLoad() + elseif name == "LEVEL SELECT" then + dataLoad() elseif name == "CREATE NEW" then newProject() elseif name == "NEXT PAGE" then @@ -197,11 +224,14 @@ function menuButtonPress(name) editLoad() end - elseif name == "BACK" or name == "CANCEL" then + elseif name == "BACK" or name == "CANCEL" or name == "MENU" then createMenu(mainmenu) elseif menu == "customs" then addMap("levels/"..name, true) mode = "play" + elseif menu == "data" then + addMap("data/"..name, true) + mode = "play" end end \ No newline at end of file diff --git a/Source/Player.lua b/Source/Player.lua index d44318c..1ccb919 100644 --- a/Source/Player.lua +++ b/Source/Player.lua @@ -31,9 +31,6 @@ sprBigRocket:setCollideRect(8,8,48,48) sprBigRocket:setGroups({2}) function addPlayer(_x,_y,__x,__y) - song:stop() - song:load("sfx/song2") - song:play(0) exists = true dead = false scale = 1 @@ -52,6 +49,7 @@ function killPlayer() exists = false active = false sprRocket:remove() + sprBigRocket:remove() gfx.setDrawOffset(0,0) end @@ -74,20 +72,20 @@ local function playerWin() if next then map = next end - playdate.datastore.delete("savegame") - playdate.datastore.write({savedLevel=map,savedDeaths=deaths},"savegame") totalEnergy = 0 showEnergy = false energy = 0 - if next == nil then - mainMenuCreation() - createMenu(mainmenu) - next = nil - else + if mode == "game" and next then + playdate.datastore.delete("savegame") + playdate.datastore.write({savedLevel=map,savedDeaths=deaths},"savegame") next = nil killBlades() killPlayer() addMapSave(map, false) + else + mainMenuCreation() + createMenu(mainmenu) + next = nil end end) diff --git a/Source/data/level.rocketbyte b/Source/data/level.rocketbyte index fd0e18c..06778ce 100644 --- a/Source/data/level.rocketbyte +++ b/Source/data/level.rocketbyte @@ -1 +1 @@ -{"bigrocket":{"x":73.333333,"y":144.79638},"next":"data/level2.rocketbyte","fuel":[{"x":73.333333,"y":100}],"dimensions":{"x":22,"y":17},"rocket":{"x":276.27907,"y":144.651163},"tiles":[{"t":2,"x":2,"y":1},{"t":2,"x":14,"y":1},{"t":2,"x":14,"y":5},{"t":2,"x":22,"y":5},{"t":2,"x":8,"y":6},{"t":2,"x":2,"y":12},{"t":2,"x":8,"y":12},{"t":2,"x":11,"y":12},{"t":2,"x":14,"y":12},{"t":2,"x":8,"y":17},{"t":2,"x":22,"y":17},{"t":3,"x":3,"y":1},{"t":3,"x":4,"y":1},{"t":3,"x":5,"y":1},{"t":3,"x":6,"y":1},{"t":3,"x":7,"y":1},{"t":3,"x":8,"y":1},{"t":3,"x":9,"y":1},{"t":3,"x":10,"y":1},{"t":3,"x":11,"y":1},{"t":3,"x":12,"y":1},{"t":3,"x":13,"y":1},{"t":3,"x":15,"y":5},{"t":3,"x":16,"y":5},{"t":3,"x":17,"y":5},{"t":3,"x":18,"y":5},{"t":3,"x":19,"y":5},{"t":3,"x":20,"y":5},{"t":3,"x":21,"y":5},{"t":3,"x":3,"y":12},{"t":3,"x":4,"y":12},{"t":3,"x":5,"y":12},{"t":3,"x":6,"y":12},{"t":3,"x":7,"y":12},{"t":3,"x":9,"y":12},{"t":3,"x":10,"y":12},{"t":3,"x":9,"y":17},{"t":3,"x":10,"y":17},{"t":3,"x":11,"y":17},{"t":3,"x":12,"y":17},{"t":3,"x":13,"y":17},{"t":3,"x":14,"y":17},{"t":3,"x":15,"y":17},{"t":3,"x":16,"y":17},{"t":3,"x":17,"y":17},{"t":3,"x":18,"y":17},{"t":3,"x":19,"y":17},{"t":3,"x":20,"y":17},{"t":3,"x":21,"y":17},{"t":4,"x":2,"y":2},{"t":4,"x":14,"y":2},{"t":4,"x":2,"y":3},{"t":4,"x":14,"y":3},{"t":4,"x":2,"y":4},{"t":4,"x":14,"y":4},{"t":4,"x":2,"y":5},{"t":4,"x":2,"y":6},{"t":4,"x":14,"y":6},{"t":4,"x":22,"y":6},{"t":4,"x":2,"y":7},{"t":4,"x":8,"y":7},{"t":4,"x":14,"y":7},{"t":4,"x":22,"y":7},{"t":4,"x":2,"y":8},{"t":4,"x":8,"y":8},{"t":4,"x":14,"y":8},{"t":4,"x":22,"y":8},{"t":4,"x":2,"y":9},{"t":4,"x":8,"y":9},{"t":4,"x":14,"y":9},{"t":4,"x":22,"y":9},{"t":4,"x":2,"y":10},{"t":4,"x":8,"y":10},{"t":4,"x":14,"y":10},{"t":4,"x":22,"y":10},{"t":4,"x":2,"y":11},{"t":4,"x":8,"y":11},{"t":4,"x":14,"y":11},{"t":4,"x":22,"y":11},{"t":4,"x":22,"y":12},{"t":4,"x":8,"y":13},{"t":4,"x":22,"y":13},{"t":4,"x":8,"y":14},{"t":4,"x":22,"y":14},{"t":4,"x":8,"y":15},{"t":4,"x":22,"y":15},{"t":4,"x":8,"y":16},{"t":4,"x":22,"y":16}]} \ No newline at end of file +{"bigrocket":{"x":73.333333,"y":144.79638},"song":"song5","next":"data/level2.rocketbyte","fuel":[{"x":73.333333,"y":100}],"dimensions":{"x":22,"y":17},"rocket":{"x":276.27907,"y":144.651163},"tiles":[{"t":2,"x":2,"y":1},{"t":2,"x":14,"y":1},{"t":2,"x":14,"y":5},{"t":2,"x":22,"y":5},{"t":2,"x":8,"y":6},{"t":2,"x":2,"y":12},{"t":2,"x":8,"y":12},{"t":2,"x":11,"y":12},{"t":2,"x":14,"y":12},{"t":2,"x":8,"y":17},{"t":2,"x":22,"y":17},{"t":3,"x":3,"y":1},{"t":3,"x":4,"y":1},{"t":3,"x":5,"y":1},{"t":3,"x":6,"y":1},{"t":3,"x":7,"y":1},{"t":3,"x":8,"y":1},{"t":3,"x":9,"y":1},{"t":3,"x":10,"y":1},{"t":3,"x":11,"y":1},{"t":3,"x":12,"y":1},{"t":3,"x":13,"y":1},{"t":3,"x":15,"y":5},{"t":3,"x":16,"y":5},{"t":3,"x":17,"y":5},{"t":3,"x":18,"y":5},{"t":3,"x":19,"y":5},{"t":3,"x":20,"y":5},{"t":3,"x":21,"y":5},{"t":3,"x":3,"y":12},{"t":3,"x":4,"y":12},{"t":3,"x":5,"y":12},{"t":3,"x":6,"y":12},{"t":3,"x":7,"y":12},{"t":3,"x":9,"y":12},{"t":3,"x":10,"y":12},{"t":3,"x":9,"y":17},{"t":3,"x":10,"y":17},{"t":3,"x":11,"y":17},{"t":3,"x":12,"y":17},{"t":3,"x":13,"y":17},{"t":3,"x":14,"y":17},{"t":3,"x":15,"y":17},{"t":3,"x":16,"y":17},{"t":3,"x":17,"y":17},{"t":3,"x":18,"y":17},{"t":3,"x":19,"y":17},{"t":3,"x":20,"y":17},{"t":3,"x":21,"y":17},{"t":4,"x":2,"y":2},{"t":4,"x":14,"y":2},{"t":4,"x":2,"y":3},{"t":4,"x":14,"y":3},{"t":4,"x":2,"y":4},{"t":4,"x":14,"y":4},{"t":4,"x":2,"y":5},{"t":4,"x":2,"y":6},{"t":4,"x":14,"y":6},{"t":4,"x":22,"y":6},{"t":4,"x":2,"y":7},{"t":4,"x":8,"y":7},{"t":4,"x":14,"y":7},{"t":4,"x":22,"y":7},{"t":4,"x":2,"y":8},{"t":4,"x":8,"y":8},{"t":4,"x":14,"y":8},{"t":4,"x":22,"y":8},{"t":4,"x":2,"y":9},{"t":4,"x":8,"y":9},{"t":4,"x":14,"y":9},{"t":4,"x":22,"y":9},{"t":4,"x":2,"y":10},{"t":4,"x":8,"y":10},{"t":4,"x":14,"y":10},{"t":4,"x":22,"y":10},{"t":4,"x":2,"y":11},{"t":4,"x":8,"y":11},{"t":4,"x":14,"y":11},{"t":4,"x":22,"y":11},{"t":4,"x":22,"y":12},{"t":4,"x":8,"y":13},{"t":4,"x":22,"y":13},{"t":4,"x":8,"y":14},{"t":4,"x":22,"y":14},{"t":4,"x":8,"y":15},{"t":4,"x":22,"y":15},{"t":4,"x":8,"y":16},{"t":4,"x":22,"y":16}]} \ No newline at end of file diff --git a/Source/gfx/add.png b/Source/gfx/add.png new file mode 100644 index 0000000..d8844ef Binary files /dev/null and b/Source/gfx/add.png differ diff --git a/Source/gfx/cursor2.png b/Source/gfx/cursor2.png new file mode 100644 index 0000000..90b0f58 Binary files /dev/null and b/Source/gfx/cursor2.png differ diff --git a/Source/gfx/line.png b/Source/gfx/line.png new file mode 100644 index 0000000..1bbc42d Binary files /dev/null and b/Source/gfx/line.png differ diff --git a/Source/gfx/music.png b/Source/gfx/music.png new file mode 100644 index 0000000..3ca0675 Binary files /dev/null and b/Source/gfx/music.png differ diff --git a/Source/gfx/spin.png b/Source/gfx/spin.png new file mode 100644 index 0000000..f05b0c4 Binary files /dev/null and b/Source/gfx/spin.png differ diff --git a/Source/gfx/square.png b/Source/gfx/square.png new file mode 100644 index 0000000..eec0222 Binary files /dev/null and b/Source/gfx/square.png differ diff --git a/Source/pdxinfo b/Source/pdxinfo index 290c19b..75b5d5c 100644 --- a/Source/pdxinfo +++ b/Source/pdxinfo @@ -4,4 +4,5 @@ description=Help a crew of rockets collect energy to get back home! bundleID=com.PossiblyAxolotl.RocketBytes version=DEV buildNumber=1 -imagePath=launcher \ No newline at end of file +imagePath=launcher +contentWarning=This game requires extremely precise and quick crank movement. \ No newline at end of file diff --git a/Source/sfx/song5.wav b/Source/sfx/song5.wav new file mode 100644 index 0000000..d092afa Binary files /dev/null and b/Source/sfx/song5.wav differ