164 lines
No EOL
4 KiB
Lua
164 lines
No EOL
4 KiB
Lua
-- PossiblyAxolotl
|
|
-- Created May 10th, 2022
|
|
-- Last updated June 28th, 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"
|
|
|
|
deaths = 0
|
|
energy = 0
|
|
totalEnergy = 0
|
|
|
|
showEnergy = false
|
|
|
|
next = nil
|
|
|
|
local gfx <const> = playdate.graphics
|
|
local disp <const> = playdate.display
|
|
local font <const> = gfx.font.new("gfx/big")
|
|
local symbols <const> = 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" 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()
|
|
end
|
|
if mode ~= "music" and mode ~= "startCutscene" and mode ~="endCutscene"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")
|
|
end
|
|
|
|
song:play(0)
|
|
|
|
function playdate.update()
|
|
if mode == "menu" then
|
|
updateMenu()
|
|
processExplosions()
|
|
elseif mode == "startCutscene" or mode == "startCutsceneReplay" then
|
|
updateStartCutscene()
|
|
elseif mode == "endCutscene" then
|
|
processEndCutscene()
|
|
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
|
|
|
|
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" then
|
|
playdate.datastore.delete("savegame.json")
|
|
playdate.datastore.write({savedLevel=map,savedDeaths=deaths},"savegame")
|
|
end
|
|
end
|
|
|
|
function playdate.debugDraw()
|
|
gfx.setDrawOffset(0,0)
|
|
gfx.drawText("DEBUG ON",0,220)
|
|
print(playdate.graphics.sprite.spriteCount())
|
|
end |