Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Maze:_process_neighbor_cells(ox, oy)
- local cellList = { {ox,oy} }
- while #cellList > 0 do
- os.queueEvent("go")
- coroutine.yield()
- local cell = table.remove(cellList,1)
- local x,y = cell[1],cell[2]
- local parent = cell[3]
- if not self.cells[y][x].is_visited then
- self.cells[y][x].is_visited = true
- local neighbor_cells = self:_shuffle(self:_get_neighbor_cells(x, y))
- if parent then
- if parent.x > x then -- open wall with right neighbor
- self.cells[y][x].right_wall = false
- self.cells[parent.y][parent.x].left_wall = false
- elseif parent.x < x then -- open wall with left neighbor
- self.cells[y][x].left_wall = false
- self.cells[parent.y][parent.x].right_wall = false
- elseif parent.y > y then -- open wall with bottom neighbor
- self.cells[y][x].bottom_wall = false
- self.cells[parent.y][parent.x].top_wall = false
- elseif parent.y < y then -- open wall with top neighbor
- self.cells[y][x].top_wall = false
- self.cells[parent.y][parent.x].bottom_wall = false
- end
- end
- for index, neighbor_cell in ipairs(neighbor_cells) do
- if self.cells[neighbor_cell.y][neighbor_cell.x].is_visited == false then
- table.insert(cellList,1,{neighbor_cell.x,neighbor_cell.y,{x=x,y=y}})
- end
- --self:_process_neighbor_cells(neighbor_cell.x, neighbor_cell.y)
- end
- end
- end
- return
- end
Advertisement
Add Comment
Please, Sign In to add comment