This commit is contained in:
2026-02-23 20:52:54 +01:00
parent fae2abf94e
commit 9eb426021e
32 changed files with 268 additions and 78 deletions

View File

@@ -1,19 +1,6 @@
Granade = {}
class('Granade').extends(NobleSprite)
local function screenShake(shakeTime, shakeMagnitude)
local shakeTimer = playdate.timer.new(shakeTime, shakeMagnitude, 0)
shakeTimer.updateCallback = function(timer)
local magnitude = math.floor(timer.value)
local shakeX = math.random(-magnitude, magnitude)
local shakeY = math.random(-magnitude, magnitude)
playdate.display.setOffset(shakeX, shakeY)
end
shakeTimer.timerEndedCallback = function()
playdate.display.setOffset(0, 0)
end
end
function Granade:init(x, y)
Granade.super.init(self)
@@ -21,12 +8,12 @@ function Granade:init(x, y)
self.currentRadius = self.initialRadius
self.shrinkRate = 0.2
random = math.random(1, 4)
local random = math.random(1, 4)
self.boomSound = playdate.sound.fileplayer.new("assets/audio/boom" .. random)
self.boomSound:setVolume(0.5)
self.isActive = true
-- Variables for random movement
self.randomMovementTimer = 0
self.randomXVelocity = 0
self.randomYVelocity = 0
@@ -35,8 +22,15 @@ function Granade:init(x, y)
self.spriteSize = size
self:setSize(size, size)
self:moveTo(x, y)
self:setZIndex(10)
self:setTag(154)
self:setCenter(0.5, 0.5)
self:setGroups(CollideGroups.granade)
self:setCollidesWithGroups({
CollideGroups.enemy
})
self:setCollideRect(0, 0, self:getSize())
print("Granade init")
print(self.x, self.y)
self:add(x, y)