From f86d0dabf0434521db88d38ffe058614c0f41fa0 Mon Sep 17 00:00:00 2001 From: yuki Date: Wed, 12 Nov 2025 00:30:18 -0300 Subject: [PATCH] add slowmo function --- main.lua | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/main.lua b/main.lua index befba7f..5308da1 100644 --- a/main.lua +++ b/main.lua @@ -31,6 +31,8 @@ Area = require 'obj/Area' GameObject = require 'obj/GameObject' function love.load() + -- slow_amntmo var + slow_amnt = 1 -- table of color palette COLORS = { default = {1,1,1,1}, @@ -87,7 +89,7 @@ function love.load() end function love.update(dt) - if current_room then current_room:update(dt) end + if current_room then current_room:update(dt*slow_amnt) end input:update(dt) if input:pressed('f1') then gotoRoom('CircleRoom') end if input:pressed('f2') and DEBUG then @@ -114,7 +116,7 @@ function love.update(dt) for k, v in pairs(counts) do print(k, v) end print("-------------------------------------") end - camera:update(dt) + camera:update(dt*slow_amnt) end function love.draw() @@ -210,6 +212,15 @@ function random(min, max) return (min > max and (love.math.random()*(min - max) + max)) or (love.math.random()*(max - min) + min) end +---Slows down gameplay +---@param amount number percentage to which game will slow down +---@param duration number duration in seconds of slow down +---@param t Timer|nil optional timer object for optimization +function slow(amount, duration, t) + local timer = t or Timer() + timer:tween(duration, _G, {slow_amnt = amount}, 'im-out-quad') +end + ------------------------ -- garbage collection -- ------------------------