generated from sage/tiny-ecs-love-template
74 lines
1.5 KiB
Lua
74 lines
1.5 KiB
Lua
require("tiny-debug")
|
|
require("utils")
|
|
require("generated/filter-types")
|
|
require("generated/assets")
|
|
require("generated/all-systems")
|
|
|
|
local world = require("world")
|
|
|
|
local scenarios = {
|
|
default = function()
|
|
-- TODO: Add default entities
|
|
end,
|
|
textTestScenario = function()
|
|
world:addEntity({
|
|
position = { x = 0, y = 600 },
|
|
drawAsText = {
|
|
text = "Hello, world!",
|
|
style = TextStyle.Inverted,
|
|
},
|
|
velocity = { x = 240, y = -500 },
|
|
mass = 1,
|
|
decayAfterSeconds = 10,
|
|
})
|
|
end,
|
|
}
|
|
|
|
local currentScenario = scenarios.textTestScenario
|
|
local freeze = false
|
|
local delta
|
|
|
|
function love.load()
|
|
currentScenario()
|
|
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()
|
|
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
|