Search code examples
javaappletawtjava-2ddrawimage

Making a checkerboard-style with graphics (java applet)


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:

It's not the way I want it

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);