bomber
This commit is contained in:
34
source/scripts/bomber/granade.lua
Normal file
34
source/scripts/bomber/granade.lua
Normal 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
|
76
source/scripts/bomber/movableCrosshair.lua
Normal file
76
source/scripts/bomber/movableCrosshair.lua
Normal 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
|
Reference in New Issue
Block a user