player ca
Player.static.sounds = {
switchFail = love.audio.newSource(sounds/switch_fail.wav),
switchSuccess = love.audio.newSource(sounds/switch_success.wav)
}
This commit is contained in:
parent
85dd66b1e4
commit
ffa35aec89
6 changed files with 46 additions and 22 deletions
16
player.lua
16
player.lua
|
|
@ -2,6 +2,11 @@ require "entity"
|
|||
|
||||
Player = class("Player", Entity)
|
||||
|
||||
Player.static.sounds = {
|
||||
switchFail = love.audio.newSource("sounds/switch_fail.wav"),
|
||||
switchSuccess = love.audio.newSource("sounds/switch_success.wav")
|
||||
}
|
||||
|
||||
function Player:initialize(x, y, activeColors)
|
||||
Entity.initialize(self, {
|
||||
x = x,
|
||||
|
|
@ -25,6 +30,17 @@ function Player:update()
|
|||
|
||||
end
|
||||
|
||||
function Player:playSwitchSound(success)
|
||||
local sound
|
||||
if success then
|
||||
sound = Player.sounds.switchSuccess
|
||||
else
|
||||
sound = Player.sounds.switchFail
|
||||
end
|
||||
sound:stop()
|
||||
sound:play()
|
||||
end
|
||||
|
||||
function Player:draw()
|
||||
for _, color in ipairs(self.activeColors) do
|
||||
love.graphics.setColor(gColor[color]:set())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue