tiny-ecs-love-template/main.lua

58 lines
1.1 KiB
Lua

require("tiny-debug")
require("utils")
require("generated/filter-types")
require("generated/assets")
require("generated/all-systems")
local scenarios = require("scenarios")
local world = require("world")
local currentScenario = scenarios.textTestScenario
local freeze = false
local delta
function love.load()
currentScenario(world)
love.graphics.setBackgroundColor(1, 1, 1)
love.graphics.setFont(EtBt7001Z0xa(32))
end
function love.update(dt)
delta = dt
if love.keyboard.isDown("r") then
world:clearEntities()
currentScenario(world)
freeze = false
end
if love.keyboard.isDown("f") then
freeze = not freeze
end
if freeze then
return
end
world:update(delta, function(_, system)
if system.deferToEnd then
return false
end
return not system.isDrawSystem
end)
end
function love.draw()
world:update(delta, function(_, system)
if system.deferToEnd then
return false
end
return system.isDrawSystem
end)
world:update(delta, function(_, system)
return system.deferToEnd
end)
end