mirror of
https://github.com/SashLilac/cambridge.git
synced 2024-11-22 14:09:03 -06:00
Changed row initialization to also use parametrized width.
This commit is contained in:
parent
0f09d47e60
commit
2d63ca8ee1
@ -129,8 +129,12 @@ function Grid:clearClearedRows()
|
|||||||
self.grid[above_row] = self.grid[above_row - 1]
|
self.grid[above_row] = self.grid[above_row - 1]
|
||||||
self.grid_age[above_row] = self.grid_age[above_row - 1]
|
self.grid_age[above_row] = self.grid_age[above_row - 1]
|
||||||
end
|
end
|
||||||
self.grid[1] = {empty, empty, empty, empty, empty, empty, empty, empty, empty, empty}
|
self.grid[1] = {}
|
||||||
self.grid_age[1] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
self.grid_age[1] = {}
|
||||||
|
for i = 1, self.width do
|
||||||
|
self.grid[1][i] = empty
|
||||||
|
self.grid_age[1][i] = 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
@ -141,23 +145,25 @@ function Grid:copyBottomRow()
|
|||||||
self.grid[row] = self.grid[row+1]
|
self.grid[row] = self.grid[row+1]
|
||||||
self.grid_age[row] = self.grid_age[row+1]
|
self.grid_age[row] = self.grid_age[row+1]
|
||||||
end
|
end
|
||||||
self.grid[24] = {empty, empty, empty, empty, empty, empty, empty, empty, empty, empty}
|
self.grid[24] = {}
|
||||||
self.grid_age[24] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
self.grid_age[24] = {}
|
||||||
for col = 1, self.width do
|
for i = 1, self.width do
|
||||||
self.grid[24][col] = (self.grid[23][col] == empty) and empty or block
|
self.grid[24][i] = (self.grid[23][i] == empty) and empty or block
|
||||||
|
self.grid_age[24][i] = 0
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function Grid:garbageRise(row_vals)
|
function Grid:garbageRise(row_vals)
|
||||||
for row = 1, 23 do
|
for row = 1, 23 do
|
||||||
self.grid[row] = self.grid[row+1]
|
self.grid[row] = self.grid[row+1]
|
||||||
self.grid_age[row] = self.grid_age[row+1]
|
self.grid_age[row] = self.grid_age[row+1]
|
||||||
end
|
end
|
||||||
self.grid[24] = {empty, empty, empty, empty, empty, empty, empty, empty, empty, empty}
|
self.grid[24] = {}
|
||||||
self.grid_age[24] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
self.grid_age[24] = {}
|
||||||
for col = 1, self.width do
|
for i = 1, self.width do
|
||||||
self.grid[24][col] = (row_vals[col] == "e") and empty or block
|
self.grid[24][i] = (row_vals[i] == "e") and empty or block
|
||||||
|
self.grid_age[24][i] = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user