We are about to switch to a new forum software. Until then we have removed the registration on this forum.
if(board[j][i] > 0) {
fill(board[j][i] ==1?255:0, board[j][i] ==2?255:0,0);
ellipse (i * bs, j * bs, bs, bs);
--How would I go about changing this to an if else statement instead of the '?'
Answers
please help
there are TWO tenerarys:
board[j][i] ==1?255:0
board[j][i] ==2?255:0
Both ask essentially :
Is board[j][i] == 1 then return 255 else return 0
Is board[j][i] == 2 then return 255 else return 0
Both resulting values are used in a fill statement.
In a 2D grid (chess board) that leads to different colors based on the value of board[j][i]
New version:
For more on understanding the ternary operator, see, the reference page:
...and a wikipedia example...