This commit is contained in:
2025-04-11 15:15:19 +02:00
parent 95b2c825db
commit 648e4a3dc4
7 changed files with 167 additions and 6 deletions

View File

@@ -0,0 +1,34 @@
Granade = {}
class('Granade').extends(NobleSprite)
function Granade:init(x, y)
Granade.super.init(self)
self.initialRadius = 10
self.currentRadius = self.initialRadius
self.shrinkRate = 0.2
self.isActive = true
self:moveTo(x, y)
print("Granade init")
print(self.x, self.y)
end
function Granade:update()
if self.isActive then
self.currentRadius = self.currentRadius - self.shrinkRate
if self.currentRadius <= 0 then
print("Granade deactivated")
self.isActive = false
self:remove()
end
end
self:draw()
end
function Granade:draw()
playdate.graphics.fillCircleAtPoint(self.x, self.y, self.currentRadius)
end

View File

@@ -0,0 +1,76 @@
MovableCrosshair = {}
class('MovableCrosshair').extends(NobleSprite)
function MovableCrosshair:init()
MovableCrosshair.super.init(self)
-- Parameters for crosshair
self.lineLength = 10
self.gapSize = 3
-- Parameters for movement
self.baseX = 200
self.baseY = 150
self.moveRadius = 2
self.moveSpeed = 2
self.time = 0
end
function MovableCrosshair:update()
-- Update time
self.time = self.time + playdate.display.getRefreshRate() / 1000
-- Calculate new position with slight movement
local offsetX = math.sin(self.time) * self.moveRadius
local offsetY = math.cos(self.time * 1.3) * self.moveRadius
self:moveTo(self.baseX + offsetX, self.baseY + offsetY)
self:draw()
end
function MovableCrosshair:draw()
-- Draw horizontal lines
playdate.graphics.drawLine(
self.x - self.lineLength - self.gapSize, self.y,
self.x - self.gapSize, self.y
)
playdate.graphics.drawLine(
self.x + self.gapSize, self.y,
self.x + self.lineLength + self.gapSize, self.y
)
-- Draw vertical lines
playdate.graphics.drawLine(
self.x, self.y - self.lineLength - self.gapSize,
self.x, self.y - self.gapSize
)
playdate.graphics.drawLine(
self.x, self.y + self.gapSize,
self.x, self.y + self.lineLength + self.gapSize
)
end
function MovableCrosshair:moveUp()
if self.baseY > 5 then
self.baseY = self.baseY - 1
end
end
function MovableCrosshair:moveDown()
if self.baseY < 235 then
self.baseY = self.baseY + 1
end
end
function MovableCrosshair:moveLeft()
if self.baseX > 5 then
self.baseX = self.baseX - 1
end
end
function MovableCrosshair:moveRight()
if self.baseX < 395 then
self.baseX = self.baseX + 1
end
end

View File

@@ -192,9 +192,9 @@ function Player:handleMovementAndCollisions()
self:boom()
return
elseif collisionTag == 154 then -- Baleba
if self.debug then
return
end
-- if self.debug then TODO: why debug always true?
-- return
-- end
self:boom(collisionObject)
return
elseif collisionTag == 2 then -- Tank