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

Commit

Permalink
Implement rolling sound
Browse files Browse the repository at this point in the history
  • Loading branch information
ShamblesSM committed Jan 20, 2023
1 parent fae3ce2 commit 030706f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/Level.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ function Level:new(data)

self.dangerSoundName = data.dangerSound or "sound_events/warning.json"
self.dangerLoopSoundName = data.dangerLoopSound or "sound_events/warning_loop.json"

self.rollingSound = _Game:playSound("sound_events/sphere_roll.json")

-- Additional variables come from this method!
self:reset()
end
Expand Down Expand Up @@ -329,7 +330,10 @@ function Level:updateLogic(dt)
if self.controlDelay then
self.controlDelay = self.controlDelay - dt
if self.controlDelay <= 0 then
self.controlDelay = nil
self.controlDelay = nil
if self.rollingSound then
self.rollingSound:stop()
end
end
end

Expand Down Expand Up @@ -376,7 +380,10 @@ function Level:updateLogic(dt)


-- Level lose
if self.lost and self:getEmpty() and not self.ended then
if self.lost and self:getEmpty() and not self.ended then
if self.rollingSound then
self.rollingSound:stop()
end
_Game.uiManager:executeCallback("levelLost")
self.ended = true
end
Expand Down Expand Up @@ -1010,7 +1017,8 @@ function Level:lose()
shotSphere:destroy()
end
self.shotSpheres = {}
_Game:playSound("sound_events/level_lose.json")
self.rollingSound = _Game:playSound("sound_events/sphere_roll.json")
_Game:playSound("sound_events/level_lose.json")
end


Expand Down

0 comments on commit 030706f

Please sign in to comment.