-- PossiblyAxolotl -- Created May 10th, 2022 -- Rocket Bytes import "CoreLibs/graphics" import "CoreLibs/sprites" import "CoreLibs/math" import "CoreLibs/animation" import "CoreLibs/animator" import "CoreLibs/timer" import "CoreLibs/easing" import "CoreLibs/keyboard" import "CoreLibs/ui" import "Cutscenes" import "Particles" import "Musicbox" import "Player" import "Map" import "Menu" import "Saws" import "Editor" mode = "menu" map = "data/level.rocketbyte" --print('app.uuid=be9bb9d6c69c403b81871f3bd14c1f36') function playdate.deviceDidUnlock() if playdate.buttonIsPressed(playdate.kButtonDown) and playdate.buttonIsPressed(playdate.kButtonB) then mode = "partTest" end end deaths = 0 energy = 0 totalEnergy = 0 showEnergy = false next = nil local gfx = playdate.graphics local disp = playdate.display local font = gfx.font.new("gfx/big") local symbols = gfx.font.new("gfx/symbols") gfx.setFont(font) gfx.setBackgroundColor(gfx.kColorBlack) song = playdate.sound.fileplayer.new("sfx/song1") song:setVolume(0.5) --song:setVolume(0.5,0.5, 1) local imgSkull = gfx.image.new("gfx/skullEmoji") local imgLightning = gfx.image.new("gfx/lightning") assert(imgSkull) assert(imgLightning) gfx.setColor(gfx.kColorWhite) mainMenuCreation() createMenu(mainmenu) tutorial = nil local menu = playdate.getSystemMenu() menuButton, error = menu:addMenuItem("game menu", function() if mode == "game" or mode == "hgame"then playdate.datastore.delete("savegame.json") playdate.datastore.write({savedLevel=map,savedDeaths=deaths,mode=mode},"savegame") elseif mode == "editor" or page == -1 then editClose() song:play(0) elseif mode == "startCutscene" or mode == "endCutscene" then local ts = playdate.timer.allTimers() song:stop() song:load("sfx/song1") createStars() for i = 1, #ts, 1 do ts[i]:remove() end song:play() end if mode =="game" or mode == "play" or mode == "hgame" then killPlayer() removeMap() killBlades() end if mode ~= "music"then totalEnergy = 0 showEnergy = false energy = 0 mainMenuCreation() createMenu(mainmenu) elseif mode == "music" then song:stop() paused = false playbackRate = 1.0 createMenu(songlist) end end) playdate.ui.crankIndicator:start() if playdate.file.exists("levels") == false then playdate.file.mkdir("levels") end if playdate.file.exists("levels/BONUS LEVEL 1.json") == false then local data = json.decodeFile("bdata/bl1.json") playdate.datastore.write(data,"levels/BONUS LEVEL 1") data = json.decodeFile("bdata/bl2.json") playdate.datastore.write(data,"levels/BONUS LEVEL 2") data = json.decodeFile("bdata/bl3.json") playdate.datastore.write(data,"levels/BONUS LEVEL 3") data = json.decodeFile("bdata/WALLZ.json") playdate.datastore.write(data,"levels/WALLZ") data = json.decodeFile("bdata/PEACE-OUT.json") playdate.datastore.write(data,"levels/PEACE-OUT") end song:play(0) function playdate.update() if mode == "menu" then updateMenu() processExplosions() elseif mode == "partTest" then testParts() elseif mode == "startCutscene" or mode == "startCutsceneReplay" then updateStartCutscene() elseif mode == "endCutscene" then processEndCutscene() elseif mode == "music" then updateBox() elseif mode == "game" or mode == "play" or mode == "hgame" then song:setVolume(0.5) updatePlayer() gfx.sprite.update() processStars(sprRocket.x-210,sprRocket.y-130) processExplosions() local ox, oy = gfx.getDrawOffset() imgSkull:draw(-ox + 1, -oy + 2) gfx.drawText(deaths,-ox + 20,-oy + 2) if showEnergy then imgLightning:draw(-ox + 1, -oy + 20) gfx.drawText(energy.."/"..totalEnergy,-ox + 20,-oy + 20) end if playdate.isCrankDocked() then playdate.ui.crankIndicator:update() end if tutorial then symbols:drawText("AOu",-ox+2,-oy + 202) end elseif mode == "newproj" then gfx.clear() updateNewproj() elseif mode == "editor" then editUpdate() if playdate.isCrankDocked() then playdate.ui.crankIndicator:update() end end updateSaws() end function playdate.gameWillTerminate() if mode == "game" or mode == "game" then playdate.datastore.delete("savegame.json") playdate.datastore.write({savedLevel=map,savedDeaths=deaths,mode=mode},"savegame") end end