Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local dir1 = math.min(bishop.x, bishop.y)
- local skip = false
- for i = 1, dir1 do
- if skip then
- break
- --either break or keep returning false...
- end
- local x = bishop.x-i+1
- local y = bishop.y-i+1
- if x == bishop.x and y == bishop.y then
- --return true, since it's the original position
- elseif grid[x][y] == false then
- --return true, since it's an empty slot
- elseif grid[x][y] == piece on the same side then
- --return false, for obvious reasons
- elseif grid[x][y] == piece of opposite side then
- skip = true
- --return true, since you can move, but set skip,
- --so no further movements can be done
- end
- end
- --dir1 would be moving top-left
- local dir2 = math.min(8-bishop.x, 8-bishop.y)
- for i = 1, dir2 do
- local x = bishop.x+i-1
- local y = bishop.y+i-1
- --do same stuff, but you'll need to reset the skip variable
- end
- --dir2 is moving down-right
- local dir3 = math.min(bishop.y, 8-bishop.x)
- for i = 1, dir3 do
- local x = bishop.x+i-1
- local y = bishop.y-i+1
- --do same stuff, but you'll need to reset the skip variable
- end
- --dir3 is moving top-right
- local dir4 = math.min(bishop.x, 8-bishop.y)
- for i = 1, dir4 do
- local x = bishop.x-i+1
- local y = bishop.y+i-1
- --do same stuff, but you'll need to reset the skip variable
- end
- --dir4 is moving bottom-left
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement