-- PossiblyAxolotl -- Created May 10th, 2022 -- Last updated June 28th, 2022 -- Rocket Bytes import "CoreLibs/graphics" import "CoreLibs/sprites" 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" 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") 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) song:play(0) 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) local menu = playdate.getSystemMenu() menuButton, error = menu:addMenuItem("game menu", function() if mode == "game" then playdate.datastore.delete("savegame.json") playdate.datastore.write({savedLevel=map,savedDeaths=deaths},"savegame") elseif mode == "editor" then editClose() song:play(0) end if mode =="game" or mode == "play" then killPlayer() removeMap() killBlades() createStars() end if mode ~= "music" then totalEnergy = 0 showEnergy = false energy = 0 mainMenuCreation() createMenu(mainmenu) else 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/ROCKETBYTES LEVEL 1.json") == false then local data = json.decodeFile("data/.bl1") playdate.datastore.write(data,"levels/ROCKETBYTES LEVEL 1") data = json.decodeFile("data/.bl2") playdate.datastore.write(data,"levels/ROCKETBYTES LEVEL 2") end function playdate.update() if mode == "menu" then updateMenu() elseif mode == "music" then updateBox() elseif mode == "game" or mode == "play" 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 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" then playdate.datastore.delete("savegame.json") playdate.datastore.write({savedLevel=map,savedDeaths=deaths},"savegame") end end