automatically gets bouif pull = true then

This commit is contained in:
0x81c 2015-03-15 18:45:24 -04:00
parent 747a7b7b58
commit 214758388e
14 changed files with 143 additions and 81 deletions

View file

@ -33,15 +33,15 @@ function Room:initialize(t)
-- self.activeColors[color] = true
-- end
-- for i=1, 30 do
-- local x, y = randomPosition()
-- local door = Door:new(x, y, self.colorsPlayerHas)
-- table.insert(self.doors, door)
for i=1, 1 do
local x, y = randomPosition()
-- local door = Door:new(x, y, self.colorsPlayerHas)
-- table.insert(self.doors, door)
-- for color, active in pairs(self.activeColors) do
-- self.collideables[color]["w: " .. x .. ", " .. y] = door
-- end
-- end
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()
@ -226,7 +226,7 @@ function Room:movePlayer(key)
local targetCells
local pull = {}
local pull
--for each color...
targetCells = {initialTargetCell} -- ...we start with our attempted movement...
local doneSearching
@ -246,7 +246,7 @@ function Room:movePlayer(key)
table.insert(nextTargetCells, projectedCell)
end
else
pull[color] = false
pull = false
doneSearching = true
end
end
@ -262,6 +262,7 @@ function Room:movePlayer(key)
--if every projected cell is empty then we can do the move
if #emptyCells == #targetCells then
pull = true
doneSearching = true
end
@ -272,8 +273,10 @@ function Room:movePlayer(key)
for _, entity in pairs(entitiesToPush) do
entity:move(axis, dir[axis])
end
for _, entity in pairs(entitiesToPull) do
entity:move(axis, dir[axis])
if pull == true then
for _, entity in pairs(entitiesToPull) do
entity:move(axis, dir[axis])
end
end
self.player[color]:move(axis, dir[axis])
moved = true