Making a checkerboard-style with graphics (java applet)
Question
OK so, I am making an applet that paints 32x32 square tiles (to make a map) and my problem is that they are going diagonally when I want them to go 8 by 8 (hence the way the array is shaped 8 by 8). So... how do I fix this?
Thanks. Anyway, since the code bbcode is being a butthead... here is the pastebin URL :-)
http://www.danflow.pastebin.com/kAUEpg1E
And here is the problem:
I want it 8 by 8... :(
Solution
The problem is this line:
g.drawImage(theTile, 32*i,32*i, this);
In order to draw it 8x8, you'll probably want to change it to something like
g.drawImage(theTile, 32*(i%8),32*(i/8), this);
OTHER TIPS
Right here: g.drawImage(theTile, 32*i,32*i, this);
So on the element when i = 2, you're tell it "Two out, Two down". The third element prints "Three out, Three down". I don't know why you're not using a two dimensional array, but to make it work with a one dimensional array I suppose you could do:
g.drawImage(theTile, 32*(i%8),32*(i/8), this);