rework + cool bomber

This commit is contained in:
2026-02-24 00:46:50 +01:00
parent 9eb426021e
commit 8a039adc05
46 changed files with 737 additions and 82 deletions

View File

@@ -0,0 +1,68 @@
AllyBullet = {}
class('AllyBullet').extends(playdate.graphics.sprite)
local killPhrases = { "stolen!", "mine!", "gotcha", "sorry :)", "too slow", "ez" }
function AllyBullet:init(targetEnemy)
AllyBullet.super.init(self)
self.target = targetEnemy
self.speed = 3
self.removed = false
self:setSize(4, 8)
self:setCenter(0.5, 0.5)
self:setZIndex(ZIndex.fx)
self:moveTo(targetEnemy.x + math.random(-30, 30), 250)
self:add()
self:markDirty()
end
function AllyBullet:update()
if self.removed then return end
-- Fly upward toward target
local dx = 0
local dy = -self.speed
if self.target and not self.target.removed and not self.target.isDying then
dx = (self.target.x - self.x) * 0.05
end
self:moveBy(dx, dy)
-- Rotate to match flight vector
local angle = math.deg(math.atan(dy, dx)) + 90
self:setRotation(angle)
-- Check if reached target
if self.target and not self.target.removed and not self.target.isDying then
local dist = math.abs(self.y - self.target.y) + math.abs(self.x - self.target.x)
if dist < 20 then
-- Kill enemy without counting toward player score
self.target:setImage(self.target.deadImage)
self.target.isDying = true
self.target.vx = math.random(-2, 2)
self.target.vy = math.random(-1, 1)
self.target:setRotation(math.random() * 360)
-- Show "stolen" text
local phrase = killPhrases[math.random(1, #killPhrases)]
FloatingText.spawnCustom(self.target.x, self.target.y, phrase)
self.removed = true
self:remove()
return
end
end
-- Off screen
if self.y < -10 then
self.removed = true
self:remove()
end
self:markDirty()
end
function AllyBullet:draw()
playdate.graphics.fillRect(0, 0, 4, 8)
end

View File

@@ -0,0 +1,71 @@
AmmoCrate = {}
class('AmmoCrate').extends(playdate.graphics.sprite)
function AmmoCrate:init(x, y)
AmmoCrate.super.init(self)
self.crateSize = 20
self:setSize(self.crateSize, self.crateSize)
self:setCenter(0.5, 0.5)
self:setZIndex(ZIndex.props)
self:setGroups(CollideGroups.props)
self:setCollidesWithGroups({ CollideGroups.granade })
self:setCollideRect(0, 0, self.crateSize, self.crateSize)
self:setTag(155)
self.removed = false
self.bonusGrenades = 3
self:moveTo(x, y)
self:add()
self:markDirty()
end
function AmmoCrate:update()
if self.removed then return end
if not BomberScene.instance then return end
self:moveBy(0, BomberScene.instance.scrollSpeed)
local _, _, collisions, count = self:checkCollisions(self.x, self.y)
if count > 0 then
for i, collision in ipairs(collisions) do
if collision.other:getTag() == 154 and collision.other.currentRadius <= 0.05 then
self:pickup()
return
end
end
end
if self.y > 260 then
self.removed = true
self:remove()
end
end
function AmmoCrate:pickup()
self.removed = true
BomberScene.availableGrenades = BomberScene.availableGrenades + self.bonusGrenades
local particle = ParticlePoly(self.x, self.y)
particle:setThickness(1)
particle:setSize(1, 2)
particle:setSpeed(1, 5)
particle:setColour(Graphics.kColorXOR)
particle:add(8)
self:remove()
end
function AmmoCrate:draw()
local s = self.crateSize
-- Box outline
playdate.graphics.drawRect(0, 0, s, s)
-- Cross pattern
playdate.graphics.drawLine(0, 0, s, s)
playdate.graphics.drawLine(s, 0, 0, s)
-- Inner + symbol
local mid = s / 2
playdate.graphics.drawLine(mid - 3, mid, mid + 3, mid)
playdate.graphics.drawLine(mid, mid - 3, mid, mid + 3)
end

View File

@@ -1,13 +1,13 @@
Enemy = {}
class('Enemy').extends(NobleSprite)
function Enemy:init(x,y)
function Enemy:init(x, y, isScout)
Enemy.super.init(self)
self:moveTo(x, y)
self:setZIndex(4)
self:add(x,y)
self.markImage = Graphics.image.new("assets/sprites/enemy"..math.random(1,2)) -- TODO: make it random
self.deadImage = Graphics.image.new("assets/sprites/enemy1_3")
self.markImage = Graphics.image.new("assets/sprites/bomber/enemy_alive_"..math.random(1,2))
self.deadImage = Graphics.image.new("assets/sprites/bomber/enemy_dead")
self.hitSound = playdate.sound.fileplayer.new("assets/audio/hit1")
self:setImage(self.markImage)
self.removed = false
@@ -18,11 +18,21 @@ function Enemy:init(x,y)
})
self:setCollideRect(-6, -6, 46, 46)
self:setSize(32, 32)
self.vx = 0
self.vy = 0
self.isDying = false
self.friction = 0.95
self.isScout = isScout or false
if self.isScout then
self.baseSpeed = math.random(8, 14) / 10
self.zigzagTime = math.random() * 100
self.zigzagAmplitude = math.random(8, 15) / 10
self.zigzagFrequency = math.random(4, 8) / 100
else
self.baseSpeed = math.random(2, 8) / 10
end
end
function Enemy:update()
@@ -40,8 +50,13 @@ function Enemy:update()
self.removed = true
end
elseif not self.removed then
speed = math.random(0, 7)/10
self:moveBy(0, BomberScene.instance.scrollSpeed + speed)
speed = self.baseSpeed + (BomberScene.enemySpeedBonus or 0)
local dx = 0
if self.isScout then
self.zigzagTime = self.zigzagTime + self.zigzagFrequency
dx = math.sin(self.zigzagTime) * self.zigzagAmplitude
end
self:moveBy(dx, BomberScene.instance.scrollSpeed + speed)
else
self:moveBy(0, BomberScene.instance.scrollSpeed)
end
@@ -89,6 +104,9 @@ function Enemy:applyExplosionForce(explosionX, explosionY)
self.vy = dy * force * 0.5
self.isDying = true
BomberScene.killCount = BomberScene.killCount + 1
FloatingText(self.x, self.y)
self:setRotation(math.random() * 360)
end

View File

@@ -4,7 +4,7 @@ class('ExplosionMark').extends(NobleSprite)
function ExplosionMark:init(x, y)
ExplosionMark.super.init(self)
self.id = math.random(1, 2)
self.markImage = Graphics.image.new("assets/sprites/boomSplash" .. self.id)
self.markImage = Graphics.image.new("assets/sprites/bomber/boom_splash_" .. self.id)
self:setImage(self.markImage)
self:moveTo(x, y)
self:setZIndex(5)

View File

@@ -0,0 +1,59 @@
FloatingText = {}
class('FloatingText').extends(playdate.graphics.sprite)
local floatFont = Graphics.font.new('assets/fonts/Mini Sans 2X')
local phrases = { "-1", "nice", "200", "dead", "done", "nice shot", "boom", "rip", "lol", "ez" }
function FloatingText.spawnCustom(x, y, text)
local ft = FloatingText(x, y)
ft.text = text
local w = floatFont:getTextWidth(text) + 4
ft:setSize(w, 16)
ft:markDirty()
return ft
end
function FloatingText:init(x, y)
FloatingText.super.init(self)
self.text = phrases[math.random(1, #phrases)]
self.life = 0
self.maxLife = 60
self.driftX = math.random(-20, 20) / 10
self.driftY = -math.random(10, 20) / 10
local w = floatFont:getTextWidth(self.text) + 4
self:setSize(w, 16)
self:setCenter(0.5, 0.5)
self:setZIndex(ZIndex.ui + 1)
self:moveTo(x, y)
self:add()
self:markDirty()
end
function FloatingText:update()
self.life = self.life + 1
if self.life >= self.maxLife then
self:remove()
return
end
self:moveBy(self.driftX, self.driftY)
self.driftY = self.driftY + 0.03
self:markDirty()
end
function FloatingText:draw()
local t = 1 - (self.life / self.maxLife)
if t > 0.5 then
floatFont:drawText(self.text, 2, 0)
else
local dither = playdate.graphics.image.kDitherTypeBayer4x4
local img = Graphics.image.new(self.width, self.height)
Graphics.pushContext(img)
floatFont:drawText(self.text, 2, 0)
Graphics.popContext()
img:drawFaded(0, 0, t * 2, dither)
end
end

View File

@@ -71,7 +71,8 @@ function Granade:update()
screenShake(1000, 5)
SmallBoom()
ExplosionMark(self.x, self.y)
SmokeCloud(self.x, self.y)
self:remove()
end
end

View File

@@ -29,9 +29,19 @@ function MovableCrosshair:update()
MovableCrosshair.super.update(self)
self.time = self.time + playdate.display.getRefreshRate() / 1000
local offsetX = math.sin(self.time) * self.moveRadius
local offsetY = math.cos(self.time * 1.3) * self.moveRadius
local radius = self.moveRadius
if NoiseAnimation.isJamming then
radius = 8
end
local offsetX = math.sin(self.time) * radius
local offsetY = math.cos(self.time * 1.3) * radius
if NoiseAnimation.isJamming then
offsetX = offsetX + math.random(-3, 3)
offsetY = offsetY + math.random(-3, 3)
end
self:moveTo(self.baseX + offsetX, self.baseY + offsetY)
self:markDirty()
end

View File

@@ -1,6 +1,9 @@
NoiseAnimation = {}
class('NoiseAnimation').extends(NobleSprite)
-- Global EW (РЕБ) state accessible by crosshair
NoiseAnimation.isJamming = false
function NoiseAnimation:init(x, y)
NoiseAnimation.super.init(self, "assets/sprites/noise", true)
self.animation:addState("run", 2, 11)
@@ -13,24 +16,40 @@ function NoiseAnimation:init(x, y)
self:moveTo(x, y)
self.state = "idle"
self.idleFrames = 0
self.timer = 0
-- РЕБ timing: long idle periods, short jam bursts
self.minIdleDuration = 300
self.maxIdleDuration = 600
self.minJamDuration = 40
self.maxJamDuration = 120
self.nextSwitch = math.random(self.minIdleDuration, self.maxIdleDuration)
end
function NoiseAnimation:update()
if self.state == "idle" then
self.idleFrames -= 1
if self.idleFrames <= 0 then
self.state = "run"
self.timer = self.timer + 1
if self.timer >= self.nextSwitch then
self.timer = 0
if self.state == "idle" then
self.state = "jamming"
self.animation:setState("run")
end
else
local r = math.random(0)
if r < 0.01 then
self.state = "idle"
self.idleFrames = math.random(30, 100)
self.animation:setState("idle")
self.nextSwitch = math.random(self.minJamDuration, self.maxJamDuration)
NoiseAnimation.isJamming = true
else
self.animation:setState("run")
self.state = "idle"
self.animation:setState("idle")
self.nextSwitch = math.random(self.minIdleDuration, self.maxIdleDuration)
NoiseAnimation.isJamming = false
playdate.display.setOffset(0, 0)
end
end
-- Micro screen shake during jamming
if self.state == "jamming" then
local sx = math.random(-1, 1)
local sy = math.random(-1, 1)
playdate.display.setOffset(sx, sy)
end
end

View File

@@ -0,0 +1,54 @@
SmokeCloud = {}
class('SmokeCloud').extends(playdate.graphics.sprite)
function SmokeCloud:init(x, y)
SmokeCloud.super.init(self)
self.radius = 25
self.maxLife = 150
self.life = self.maxLife
local size = self.radius * 2 + 4
self:setSize(size, size)
self:setCenter(0.5, 0.5)
self:setZIndex(ZIndex.fx - 1)
self:moveTo(x, y)
self:add()
self:markDirty()
end
function SmokeCloud:update()
if not BomberScene.instance then
self:remove()
return
end
self:moveBy(0, BomberScene.instance.scrollSpeed)
self.life = self.life - 1
if self.life <= 0 or self.y > 280 then
self:remove()
return
end
self:markDirty()
end
function SmokeCloud:draw()
local t = self.life / self.maxLife
local r = self.radius * t
local cx = self.width / 2
local cy = self.height / 2
local dither = playdate.graphics.image.kDitherTypeBayer4x4
if t < 0.3 then
dither = playdate.graphics.image.kDitherTypeBayer8x8
elseif t < 0.6 then
dither = playdate.graphics.image.kDitherTypeBayer4x4
end
playdate.graphics.setColor(playdate.graphics.kColorBlack)
playdate.graphics.setDitherPattern(1 - t * 0.6, dither)
playdate.graphics.fillCircleAtPoint(cx, cy, r)
playdate.graphics.setColor(playdate.graphics.kColorBlack)
end

View File

@@ -2,7 +2,7 @@ Ground = {}
class("Ground").extends(NobleSprite)
function Ground:init(x, y, player)
Ground.super.init(self, "assets/sprites/groundFin")
Ground.super.init(self, "assets/sprites/ground_2")
-- Collision properties
self:setZIndex(ZIndex.ground)

View File

@@ -3,18 +3,11 @@ Tank = {}
class("Tank").extends(Graphics.sprite)
function Tank:init(x, y, ground)
self.tankImage = Graphics.image.new("assets/sprites/tank")
self.tankImageD = Graphics.image.new("assets/sprites/tankD")
local target = Targets[CurrentMission.targetIndex]
self.tankImage = Graphics.image.new(target.sprite)
self.tankImageD = Graphics.image.new(target.spriteD)
Tank.super.init(self)
local width, height = self.tankImage:getSize()
self.faded_image = Graphics.image.new(width, height, Graphics.kColorClear)
Graphics.pushContext(self.faded_image)
self.tankImageD:drawBlurred(0, 0, 2, 2, Graphics.image.kDitherTypeFloydSteinberg)
Graphics.popContext()
-- Collision properties
self:setZIndex(ZIndex.enemy)
self:setTag(2)
@@ -38,7 +31,7 @@ function Tank:fadein()
end
function Tank:fadeout()
self:setImage(self.faded_image)
self:setImage(self.tankImageD)
end
function Tank:update()