We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello everybody,
I just get started with processing some days ago so I hope somebody can help me with my problem:
I've written a code for a chessboard but I don't know how to letter the individual fields. Down on the left side i wanted "A1", right next to it "B1" etc. How can I do it?
I hope someone can help me and sorry for my bad english - I'm from Denmark :)
Answers
You can make a nested for loop
Double for loop
One is for lines other for columns
To get A1 say
char(i+65) + str(j)
Or so
Use text()
See reference
0
.int idx = ch - 'A';
.String field = "D3";
. The we get:char ch = field.charAt(0);
.int idx = ch - 'A';
, we have:int idx = 'D' - 'A';
. Result is:idx = 3
. *-:)See also reference on for
Sorry I think I'm too stupid but it doesn't work.
edit post, highlight code, press ctrl-o to format it nicely.
start by printing a bit of text, any bit of text, anywhere...
now move that text to the right place.
then modify that to print all the x text in the correct positions.
then write a loop that'll do that.
do the same for y positions.
There is a color selector in menu tools so that you can pick nicer brown colors - or see Wikipedia for colors : https://en.wikipedia.org/wiki/Chess
The colors used there are [rgb] :
which I found out with this simple sketch :
The code above looks okay; after
rect
sayfill(111);
and thentext(....
what I have above - replacei j
withx y
obviouslyPost this
I once downloaded the images from Wikipedia and took them for the figures
Please edit the spelling in your post title:
Your chessboard (share the code!) probably uses nested loops -- a loop to draw each row, and a loop inside that to draw each square of each row.
As @Chrisir suggests, you can print letters or numbers separately:
...so combine these loops in the same way (or at the same time) as you combine the loops to draw your squares. To draw the text to the screen instead of the console, use
text()
.Have you removed your code...? Why? This can be seen as rude here by some. (My answer is not understandable now anymore and it makes me look like a moron).
Please correct the title from
Cheesboard to Chessboard
Thank you!
Please don't remove your code like this