From 0414abf60422b5eb9cb2d5e4d5eb09d880ee18d1 Mon Sep 17 00:00:00 2001 From: Rodrigo Delduca <46259+skhaz@users.noreply.github.com> Date: Fri, 17 Nov 2023 14:37:10 -0300 Subject: [PATCH] Work in progress --- scripts/main.lua | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 scripts/main.lua diff --git a/scripts/main.lua b/scripts/main.lua new file mode 100644 index 0000000..b72bd4f --- /dev/null +++ b/scripts/main.lua @@ -0,0 +1,37 @@ +local engine = EngineFactory.new() + :set_title("Carimbo") + :set_width(854) + :set_height(480) + :set_fullscreen(false) + :create() + +local squares = {} + +for i = 1, 16 do + local name = string.format("blob/%02d.avif", i) + table.insert(squares, name) +end + +engine:prefetch(squares) + +for _, name in ipairs(squares) do + local square = engine:spawn() + square.pixmap = name + square.on_update = function(self) + self.x = math.random(0, 854) + self.y = math.random(0, 480) + self.angle = math.random(0, 360) + end +end + +local gc = engine:spawn() + +gc:on_update(function(self) + if collectgarbage("count") / 1024 > 8 then + collectgarbage("collect") + else + collectgarbage("step", 1) + end +end) + +engine:run()