Mothback/code/game.lua

100 lines
1.9 KiB
Lua

function stepGame()
setCollisionFlags()
if menu_type == "no" then
for _, particle in pairs(LoadedParticles) do
particle:doLogic()
end
for _, enty in pairs(LoadedObjects.Entities) do
enty:doLogic()
end
end
for _, particle in pairs(LoadedObjects.Particles) do
particle:doPhysics()
end
for _, enty in pairs(LoadedObjects.Entities) do
enty:doPhysics()
end
AnimateTiles()
Camera:followPlayer(main_Player)
--Camera:positionCenterAt(main_Player.pos.x, main_Player.pos.y)
--camera:positionAt(main_Player.pos.x, main_Player.pos.y,game.width,game.height)
if Keybind:CheckPressed(Keybind.debug.debug) then
if debug then
debug = false
debug_collision = true
elseif debug_collision then
debug_collision = false
else
debug = true
end
end
if Keybind:CheckPressed(Keybind.debug.reposition) then
if not editor_mode then
main_Player.pos.x, main_Player.pos.y = 16,-10
end
end
if Keybind:CheckPressed(Keybind.debug.reload) then
MenuClear()
menu_type = "dialog"
MenuInit("dialog",DialogSequence.Example)
end
if Keybind:CheckPressed(Keybind.debug.editor) then
editor_mode = true
end
if Keybind:CheckPressed(Keybind.debug.recording) then
if DemoRecording then
Demo:endRecord()
else
Demo:startRecord()
end
end
if Keybind:CheckPressed(Keybind.debug.playback) then
if DemoPlayback then
Demo:endPlayback()
else
Demo:startPlayback()
end
end
end
function drawGame()
-- prepare
startGameworldDraw()
updateGameWorldLights()
-- background
drawGameworldBackground()
drawGameworldLights()
drawGameworldEntitiesBackground()
-- foreground
drawGameworldForeground()
drawGameworldParticles()
drawGameworldEntities()
if LevelData.properties.darkness then
drawGameworldDarkness()
end
-- end
endGameworldDraw()
-- hud
textScale = 1
-- debug
if debug then debugUI() end
if debug_collision then
debugColisions()
debugEntities()
end
end