Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
Blitz Meter now almost fully functional
Browse files Browse the repository at this point in the history
The values have been carefully investigated and they match
the OG ZB nearly perfectly.
  • Loading branch information
jakubg1 committed Jan 1, 2023
1 parent 8f9e45b commit fd493a5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 12 deletions.
37 changes: 31 additions & 6 deletions src/Level.lua
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,19 @@ function Level:updateLogic(dt)

-- Hot Frog handling
if self.started and not self.controlDelay and not self:getFinish() and not self.finish and not self.lost then
local gracePeriod = 3 -- In seconds
self.timeSinceLastSuccessfulShot = self.timeSinceLastSuccessfulShot + dt
if self.timeSinceLastSuccessfulShot > gracePeriod then
self.blitzMeter = 0
end
if self.blitzMeter == 1 then
-- We're in hot frog mode, reset once the shooter has a ball other than the fireball.
if self.shooter.color > 0 then
self.blitzMeter = 0
self.blitzMeterCooldown = 0
end
else
if self.blitzMeterCooldown == 0 then
self.blitzMeter = math.max(self.blitzMeter - 0.03 * dt, 0)
else
self.blitzMeterCooldown = math.max(self.blitzMeterCooldown - dt, 0)
end
end
end


Expand Down Expand Up @@ -679,6 +687,19 @@ end



---Increments the level's Blitz Meter by a given amount and launches the Hot Frog if reaches 1.
---@param amount any
function Level:incrementBlitzMeter(amount)
self.blitzMeter = math.min(self.blitzMeter + amount, 1)
if self.blitzMeter == 1 then
-- hot frog
self.shooter:getMultiSphere(-2, 3)
end
_Debug.console:print("blitzMeter: " .. self.blitzMeter)
end



---Returns `true` when there are no more spheres on the board and no more spheres can spawn, too.
---@return boolean
function Level:hasNoMoreSpheres()
Expand Down Expand Up @@ -782,7 +803,7 @@ function Level:reset()
self.time = 0

self.blitzMeter = 0
self.timeSinceLastSuccessfulShot = 0
self.blitzMeterCooldown = 0

self.spheresShot = 0
self.sphereChainsSpawned = 0
Expand Down Expand Up @@ -923,6 +944,8 @@ function Level:serialize()
maxCombo = self.maxCombo
},
time = self.time,
blitzMeter = self.blitzMeter,
blitzMeterCooldown = self.blitzMeterCooldown,
controlDelay = self.controlDelay,
finish = self.finish,
finishDelay = self.finishDelay,
Expand Down Expand Up @@ -966,6 +989,8 @@ function Level:deserialize(t)
self.combo = t.combo
self.destroyedSpheres = t.destroyedSpheres
self.time = t.time
self.blitzMeter = t.blitzMeter
self.blitzMeterCooldown = t.blitzMeterCooldown
self.lost = t.lost
-- Utils
self.controlDelay = t.controlDelay
Expand Down
1 change: 1 addition & 0 deletions src/ShotSphere.lua
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ function ShotSphere:moveStep()
self.hitSphere = nil -- avoid deleting this time
else
_Game:playSound(badShot and sphereConfig.hitSoundBad or sphereConfig.hitSound, 1, self.pos)
_Game.session.level.blitzMeterCooldown = 0.5
end
end
end
Expand Down
7 changes: 1 addition & 6 deletions src/SphereGroup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -668,12 +668,7 @@ function SphereGroup:matchAndDeleteEffect(position, effect)
self.map.level.maxChain = math.max(self.sphereChain.combo, self.map.level.maxChain)

-- Update Hot Frog meter
if boostCombo then
self.map.level.timeSinceLastSuccessfulShot = 0
self.map.level.blitzMeter = self.map.level.blitzMeter + math.max(0.05 * (3 - self.map.level.timeSinceLastSuccessfulShot), 0)
_Debug.console:print("add: "..math.max(0.05 * (3 - self.map.level.timeSinceLastSuccessfulShot), 0))
_Debug.console:print("blitzMeter: "..self.map.level.blitzMeter)
end
self.map.level:incrementBlitzMeter(0.055)
end


Expand Down
1 change: 1 addition & 0 deletions src/UI/Manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function UIManager:new()
levelGetChains = function() return _Game.session.level.sphereChainsSpawned end,
levelGetMaxCombo = function() return _Game.session.level.maxCombo end,
levelGetMaxChain = function() return _Game.session.level.maxChain end,
levelGetBlitzMeter = function() return _Game.session.level.blitzMeter end,

musicVolume = function(music, volume) _Game:getMusic(music):setVolume(volume) end,

Expand Down

0 comments on commit fd493a5

Please sign in to comment.