Compare commits
No commits in common. "3b83851fb9f97b2803a3be6a3984349d06f9cbc4" and "e824579d5e729e0df20a3d5943769be689400f2f" have entirely different histories.
3b83851fb9
...
e824579d5e
5 changed files with 17 additions and 17 deletions
14
main.lua
14
main.lua
|
|
@ -33,10 +33,6 @@ GameObject = require 'obj/GameObject'
|
|||
function love.load()
|
||||
-- slowmo var
|
||||
slow_amnt = 1
|
||||
|
||||
-- global timer
|
||||
timer = Timer()
|
||||
|
||||
-- table of color palette
|
||||
COLORS = {
|
||||
default = {1,1,1,1},
|
||||
|
|
@ -120,7 +116,6 @@ function love.update(dt)
|
|||
for k, v in pairs(counts) do print(k, v) end
|
||||
print("-------------------------------------")
|
||||
end
|
||||
timer:update(dt*slow_amnt)
|
||||
camera:update(dt*slow_amnt)
|
||||
end
|
||||
|
||||
|
|
@ -173,17 +168,10 @@ function gotoRoom(room_type, ...)
|
|||
error("room '"..room_type.."' is not callable (got "..type(Class)..", does room return itself?)")
|
||||
end
|
||||
if current_room and current_room.destroy then current_room:destroy() end
|
||||
if slow_amnt ~= 1 then slow_amnt = 1 end
|
||||
current_room = _G[room_type](...)
|
||||
end
|
||||
|
||||
---Slows down gameplay
|
||||
---@param amount number percentage to which game will slow down
|
||||
---@param duration number duration in seconds of slow down
|
||||
function slow(amount, duration)
|
||||
slow_amnt = amount
|
||||
timer:tween(duration, _G, {slow_amnt = 1}, 'in-out-cubic')
|
||||
end
|
||||
|
||||
---Generates and returns random UUID string
|
||||
---@return string
|
||||
function UUID()
|
||||
|
|
|
|||
13
obj/Area.lua
13
obj/Area.lua
|
|
@ -11,6 +11,7 @@ function Area:new(room)
|
|||
self.room = room
|
||||
self.game_objects = {}
|
||||
self.world = nil
|
||||
self.timer = Timer()
|
||||
end
|
||||
|
||||
---Updates area
|
||||
|
|
@ -25,6 +26,7 @@ function Area:update(dt)
|
|||
table.remove(self.game_objects, i)
|
||||
end
|
||||
end
|
||||
self.timer:update(dt)
|
||||
end
|
||||
|
||||
---Draws area
|
||||
|
|
@ -40,8 +42,7 @@ function Area:destroy()
|
|||
end
|
||||
for i = #self.game_objects, 1, -1 do
|
||||
local game_object = self.game_objects[i]
|
||||
---@diagnostic disable-next-line: invisible
|
||||
game_object:destroy()
|
||||
game_object:kill()
|
||||
table.remove(self.game_objects, i)
|
||||
end
|
||||
self.game_objects = {}
|
||||
|
|
@ -67,4 +68,12 @@ function Area:addCollisionManager(cell_size)
|
|||
self.world = HC(cell_size or 100)
|
||||
end
|
||||
|
||||
---Slows down gameplay
|
||||
---@param amount number percentage to which game will slow down
|
||||
---@param duration number duration in seconds of slow down
|
||||
function Area:slow(amount, duration)
|
||||
slow_amnt = amount
|
||||
self.timer:tween(duration, _G, {slow_amnt = 1}, 'in-out-cubic')
|
||||
end
|
||||
|
||||
return Area
|
||||
|
|
|
|||
|
|
@ -52,6 +52,10 @@ end
|
|||
|
||||
---Destroys room
|
||||
function Room:destroy()
|
||||
if self.timer then
|
||||
self.timer:clear() -- cancel all tweens/after/every
|
||||
self.timer = nil
|
||||
end
|
||||
self.area:destroy()
|
||||
self.area = nil
|
||||
end
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ function Player:kill()
|
|||
for i=1, random(8,12) do
|
||||
self.area:addGameObject('ExplodeParticle', self.x, self.y)
|
||||
end
|
||||
slow(.15, 1)
|
||||
self.area:slow(.15, 1)
|
||||
camera:shake(6, 60, .4)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ end
|
|||
|
||||
function Stage:update(dt)
|
||||
Stage.super.update(self, dt)
|
||||
if input:pressed('action') then gotoRoom('Stage') end
|
||||
end
|
||||
|
||||
function Stage:canvasDraw()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue