From 42ec7b74fc558d307b2d4d6e6b5efbe4043611b9 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 5 Mar 2025 19:43:18 -0500 Subject: [PATCH] Implicitly add all systems created through filteredSystem() to the world --- src/main.lua | 26 +++++++------------------- src/tiny-tools.lua | 4 ++-- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/main.lua b/src/main.lua index 02b6c1c..529c20b 100644 --- a/src/main.lua +++ b/src/main.lua @@ -8,6 +8,10 @@ import("CoreLibs/ui.lua") import("CoreLibs/utilities/where.lua") import("../lib/tiny.lua") + +local tiny = 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 = tiny local gfx = 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) diff --git a/src/tiny-tools.lua b/src/tiny-tools.lua index ebcd3c4..a7cf0ab 100644 --- a/src/tiny-tools.lua +++ b/src/tiny-tools.lua @@ -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