Skip to content

Commit

Permalink
Fix music being started multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
Top-Cat committed Dec 16, 2013
1 parent e687b11 commit 62b3ae5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
7 changes: 6 additions & 1 deletion main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ function love.load()
music = love.audio.newSource("sound/golden-streets.mp3")
music:setLooping(true)
love.audio.play(music)
setManager(Menu:new(setManager, love.load))

restart()
end

function restart()
setManager(Menu:new(setManager, restart))
end

function love.update(dt)
Expand Down
4 changes: 2 additions & 2 deletions manager/game.lua
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,13 @@ function Game:update(dt)

if self.state[self.playerId] and self.state[self.playerId].health <= 0 then
-- Player is dead.
self.setManager(GameOver:new(setManager, love.load))
self.setManager(GameOver:new(setManager, restart))
return
end

if self.state[self.playerId] ~= nil and self.state[self.playerId].y > 800 then
--Falling Death
self.setManager(GameOver:new(setManager, love.load))
self.setManager(GameOver:new(setManager, restart))
return
end

Expand Down
4 changes: 2 additions & 2 deletions manager/levelcomplete.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ end
function LevelComplete:load()
self.backgroundImage = love.graphics.newImage("assets/levelcomplete.png")
if self.nextLevel == 4 then
self.setManager(Victory:new(setManager, love.load))
self.setManager(Victory:new(setManager, restart))
end
end

function LevelComplete:keypressed(key, unicode)
if key == "return" then
self.setManager(Game:new(self.class.levels[self.nextLevel], self.nextLevel,
setManager, love.load))
setManager, restart))
end
end

Expand Down
2 changes: 1 addition & 1 deletion manager/victory.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ end

function Victory:keypressed(key, unicode)
if key == "return" then
self.setManager(Menu:new(setManager, love.load))
self.setManager(Menu:new(setManager, restart))
end
end

Expand Down

0 comments on commit 62b3ae5

Please sign in to comment.