rework + cool bomber
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user