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

@ -25,13 +25,12 @@ function Room:initialize(t)
red = true, green = true, blue = true
}
-- for color, coords in pairs(t.player) do
-- self.player[color] = Player:new(coords.x, coords.y, color)
-- self.activeColors[color] = true
-- end
for i=1, 3 do
for i=1, 5 do
local x, y = randomPosition()
local door = Door:new(x, y, self.colorsPlayerHas)
table.insert(self.doors, door)
@ -41,12 +40,12 @@ function Room:initialize(t)
end
end
-- for i=0, 5 do
-- local x, y = math.random(1, gridWidth), math.random(1, gridHeight)
-- for color, active in pairs(self.activeColors) do
-- self.collideables[color]["w: " .. x .. ", " .. y] = Wall:new(x, y, color)
-- end
-- end
for i=0, 5 do
local x, y = randomPosition()
for color, active in pairs(self.activeColors) do
self.collideables[color]["w: " .. x .. ", " .. y] = Box:new(x, y, color)
end
end
for i = 0, 5 do
local x, y = randomPosition()
@ -301,17 +300,22 @@ function Room:movePlayer(key)
end
end
function Room:attemptPush(dirVector)
-- should return array of things to push or nil/falsey value
end
function Room:switchPlayerColor(color)
if color == "white" then
self.player:setActiveColors({"red", "green", "blue"})
else
self.player:setActiveColors({color})
local colors
if color == "white" then colors = {"red", "green", "blue"} else colors = {color} end
local canSwitch = true
local playerPos = self.player:getGridPos()
for _, color in ipairs(colors) do
if self:getCellInMatrix(self.collidableMatrices[color], playerPos) then
canSwitch = false
end
end
if canSwitch then
self.player:setActiveColors(colors)
end
self.player:playSwitchSound(canSwitch)
end
function Room:setActiveColor(color, bool)