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:
0x81c 2015-03-15 08:00:59 -04:00
parent 85dd66b1e4
commit ffa35aec89
6 changed files with 46 additions and 22 deletions

View file

@ -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())