Implicitly add all systems created through filteredSystem() to the world

This commit is contained in:
Sage Vaillancourt 2025-03-05 19:43:18 -05:00
parent 94b391801d
commit 42ec7b74fc
2 changed files with 9 additions and 21 deletions

View File

@ -8,6 +8,10 @@ import("CoreLibs/ui.lua")
import("CoreLibs/utilities/where.lua")
import("../lib/tiny.lua")
local tiny <const> = tiny
world = tiny.world()
import("tiny-tools.lua")
import("assets.lua")
import("systems/filter-types.lua")
@ -24,7 +28,6 @@ import("ingredients/ingredients.lua")
import("cart.lua")
import("utils.lua")
local tiny <const> = tiny
local gfx <const> = playdate.graphics
playdate.display.setRefreshRate(50)
gfx.setBackgroundColor(gfx.kColorWhite)
@ -58,24 +61,8 @@ function Score:draw()
gfx.drawText("Z|" .. self.points, 360, 5)
end
world = tiny.world(
fallSystem,
moveTowardSystem,
velocitySystem,
roundSystem,
spawnerSystem,
expireBelowScreenSystem,
collectedEntities,
collidingEntities,
collisionResolution,
collisionDetection,
cameraPanSystem,
drawRectanglesSystem,
drawSpriteSystem,
drawTextSystem,
floor,
cart
)
world:addEntity(floor)
world:addEntity(cart)
addAllSpawners(world)
world:addEntity(Ingredients.getFirst())
@ -86,6 +73,7 @@ playdate.setAutoLockDisabled(true)
function playdate.update()
local deltaSeconds = playdate.getElapsedTime()
playdate.resetElapsedTime()
playdate.timer.updateTimers()
gfx.clear(gfx.kColorWhite)
playdate.drawFPS(5, 5)

View File

@ -24,7 +24,7 @@ function filteredSystem(shape, process)
end
system.filter = tiny.requireAll(table.unpack(keys))
if not process then
return system
return world:addSystem(system)
end
if isSimulator then
-- local acceptableKeys = ""
@ -54,5 +54,5 @@ function filteredSystem(shape, process)
process(e, dt, self)
end
end
return system
return world:addSystem(system)
end