Rocket-Bytes/Source/Main.lua
PossiblyAxolotl e1164a66bc fixes
2022-05-08 22:31:57 -06:00

74 lines
No EOL
1.6 KiB
Lua

import "CoreLibs/graphics"
import "CoreLibs/sprites"
import "CoreLibs/ui"
import "Player"
import "Map"
import "Menu"
import "Saws"
import "Editor"
mode = "menu"
map = "levels/level1.json"
deaths = 0
local gfx <const> = playdate.graphics
local disp <const> = playdate.display
local font <const> = gfx.font.new("gfx/big")
dev = false
gfx.setFont(font)
gfx.setBackgroundColor(gfx.kColorBlack)
song = playdate.sound.fileplayer.new("sfx/song1")
song:play(0)
local imgCrank = gfx.image.new("gfx/crank")
gfx.setColor(gfx.kColorWhite)
-- {"START NEW GAME","CONTINUE","USER LEVELS", "EXIT"}
mainMenuCreation()
createMenu(mainmenu)
local menu = playdate.getSystemMenu()
local menuItem, error = menu:addMenuItem("Main Menu", function()
if mode == "game" then
playdate.datastore.write({savedLevel=map,savedDeaths=deaths},"savegame")
end
mainMenuCreation()
createMenu(mainmenu)
end)
--addMap("levels/level.json")
function playdate.update()
if mode == "menu" then
updateMenu()
elseif mode == "game" or mode == "play" then
updatePlayer()
gfx.sprite.update()
local ox, oy = gfx.getDrawOffset()
gfx.drawText(deaths,-ox + 1,-oy + 1)
elseif mode == "newproj" then
gfx.clear()
updateNewproj()
end
if dev then
local ox, oy = gfx.getDrawOffset()
playdate.drawFPS(0,20)
gfx.drawText(playdate.getCrankPosition(), -ox, -oy + 35)
gfx.drawText(deaths, -ox, -oy + 55)
end
updateSaws()
end
function playdate.gameWillTerminate()
if mode == "game" then
playdate.datastore.write({savedLevel=map,savedDeaths=deaths},"savegame")
end
end