3 answers
-
Please post the code directly, as an image is unusable.
(Note, I’m waiting for this before proposing a solution)
--
I mainly work in VB6 and VB.NET, with a bit of C#, but moderation often leads me to other languages.
In VB.NET, remember to enable "Option Explicit" and "Option Strict"-
Here is the code translated into English while preserving structure:
size(500,500); for(int i=0; i<10; i++){ if(i%2!=0){ noStroke(); fill(255,255,255); } else{ noStroke(); fill(0,0,0); } for(int j=0; j<10; j++){ if(j%2!=0){ noStroke(); fill(255); } else{ noStroke(); fill(0); } rect(50*j,50*i,50,50);}}
-
-
Hello,
It would be nice to use the automatic formatting (Ctrl+T) to better see the nesting of the blocks with each other. Looking at your code like this, it seems the loops follow one another, whereas in reality they are nested.
Otherwise, your first if is useless since the second for loop will redraw over it anyway.
In any case, you cannot determine whether a square is white or black using only its row or only its column; you need both pieces of information at the same time to know which color to draw.
Note: since you always have noStroke, there is no point in applying it every time; one time at the beginning is enough.
--
Trust does not exclude control. -
Is there a way to make a checkerboard, but it’s a question of if you need 3 if statements, so 2 nested ones, I’ll search for the code.