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/assets")
|
||||||
require("generated/all-systems")
|
require("generated/all-systems")
|
||||||
|
|
||||||
local world = require("world")
|
local scenarios = require("scenarios")
|
||||||
|
|
||||||
local scenarios = {
|
local world = require("world")
|
||||||
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 currentScenario = scenarios.textTestScenario
|
||||||
local freeze = false
|
local freeze = false
|
||||||
local delta
|
local delta
|
||||||
|
|
||||||
function love.load()
|
function love.load()
|
||||||
currentScenario()
|
currentScenario(world)
|
||||||
love.graphics.setBackgroundColor(1, 1, 1)
|
love.graphics.setBackgroundColor(1, 1, 1)
|
||||||
love.graphics.setFont(EtBt7001Z0xa(32))
|
love.graphics.setFont(EtBt7001Z0xa(32))
|
||||||
end
|
end
|
||||||
|
@ -39,7 +23,7 @@ function love.update(dt)
|
||||||
|
|
||||||
if love.keyboard.isDown("r") then
|
if love.keyboard.isDown("r") then
|
||||||
world:clearEntities()
|
world:clearEntities()
|
||||||
currentScenario()
|
currentScenario(world)
|
||||||
freeze = false
|
freeze = false
|
||||||
end
|
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