Mothback/code/game.lua

99 lines
1.9 KiB
Lua
Raw Permalink Normal View History

function GameStep()
2022-02-26 02:56:53 +00:00
SetCollisionFlags()
if menu_type == "no" then
for _, particle in pairs(LoadedParticles) do
particle:Smart()
end
for _, enty in pairs(LoadedObjects.Entities) do
enty:Smart()
end
end
2022-01-30 10:31:18 +00:00
2022-02-26 02:56:53 +00:00
for _, particle in pairs(LoadedObjects.Particles) do
particle:DoPhysics()
end
for _, enty in pairs(LoadedObjects.Entities) do
enty:DoPhysics()
end
2022-02-26 02:56:53 +00:00
AnimateTiles()
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
2022-01-30 10:31:18 +00:00
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
2022-01-30 10:31:18 +00:00
if not editor_mode then
main_Player.pos.x, main_Player.pos.y = 16,-10
end
end
if Keybind:CheckPressed(Keybind.debug.reload) then
2022-02-26 02:56:53 +00:00
MenuClear()
menu_type = "dialog"
MenuInit("dialog",DialogSequence.Example)
2022-01-30 10:31:18 +00:00
end
if Keybind:CheckPressed(Keybind.debug.editor) then
2022-01-30 10:31:18 +00:00
editor_mode = true
end
if Keybind:CheckPressed(Keybind.debug.recording) then
if DemoRecording then
2022-02-26 02:56:53 +00:00
Demo:RecordEnd()
else
Demo:RecordStart()
end
end
2022-02-26 02:56:53 +00:00
if Keybind:CheckPressed(Keybind.debug.playback) then
if DemoPlayback then
Demo:PlaybackEnd()
else
Demo:PlaybackStart()
end
end
end
function GameDraw()
2022-02-26 02:56:53 +00:00
-- prepare
GameworldDrawPrepare()
GameWorldUpdateLights()
2022-02-26 02:56:53 +00:00
-- background
GameworldDrawBackground()
GameworldDrawLights()
GameworldDrawEntitiesBackground()
2022-02-26 02:56:53 +00:00
-- foreground
GameworldDrawForeground()
GameworldDrawParticles()
GameworldDrawEntities()
2022-02-26 02:56:53 +00:00
if LevelData.properties.darkness then
GameworldDrawDarkness()
end
-- end
GameworldDrawEnd()
-- hud
textScale = 1
2022-02-26 02:56:53 +00:00
-- debug
if debug then DebugUI() end
if debug_collision then
DebugColisions()
DebugEntities()
end
end