Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- The grid was clicked
- function gridClicked(x, y, b)
- if ((x > 0) and (y > 0) and (x <= w) and (y <= h)) then
- if b == 1 then
- local sweep = {}
- local swept = {}
- local function isSwept(x,y)
- if swept[x] == nil or swept[x][y] == nil then return false end
- return true
- end
- local function addSweep(x,y)
- table.insert(sweep,{x,y})
- end
- local function addSwept(x,y)
- if swept[x] == nil then swept[x] = {} end
- swept[x][y] = true
- end
- addSweep(x,y)
- while #sweep > 0 do
- local x,y = unpack(table.remove(sweep,1))
- addSwept(x,y)
- if devoil[x][y] == 0 then
- displaySquare(x, y)
- if grille[x][y] == 0 then
- for u = -1, 1 do
- for v = -1, 1 do
- if not isSwept(x+u,y+v) then
- addSweep(x+u,y+v,1)
- end
- end
- end
- end
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement