Extract scenarios.lua
This commit is contained in:
parent
1daf9b541f
commit
1dda9c258a
24
main.lua
24
main.lua
|
@ -4,32 +4,16 @@ require("generated/filter-types")
|
|||
require("generated/assets")
|
||||
require("generated/all-systems")
|
||||
|
||||
local world = require("world")
|
||||
local scenarios = require("scenarios")
|
||||
|
||||
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 world = require("world")
|
||||
|
||||
local currentScenario = scenarios.textTestScenario
|
||||
local freeze = false
|
||||
local delta
|
||||
|
||||
function love.load()
|
||||
currentScenario()
|
||||
currentScenario(world)
|
||||
love.graphics.setBackgroundColor(1, 1, 1)
|
||||
love.graphics.setFont(EtBt7001Z0xa(32))
|
||||
end
|
||||
|
@ -39,7 +23,7 @@ function love.update(dt)
|
|||
|
||||
if love.keyboard.isDown("r") then
|
||||
world:clearEntities()
|
||||
currentScenario()
|
||||
currentScenario(world)
|
||||
freeze = false
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
local scenarios = {}
|
||||
|
||||
---@param world World
|
||||
function scenarios.default(world)
|
||||
-- TODO: Add default entities
|
||||
end
|
||||
|
||||
---@param world World
|
||||
function scenarios.textTestScenario(world)
|
||||
world:addEntity({
|
||||
position = { x = 0, y = 600 },
|
||||
drawAsText = {
|
||||
text = "Hello, world!",
|
||||
style = TextStyle.Inverted,
|
||||
},
|
||||
velocity = { x = 240, y = -500 },
|
||||
mass = 1,
|
||||
decayAfterSeconds = 10,
|
||||
})
|
||||
end
|
||||
|
||||
return scenarios
|
Loading…
Reference in New Issue