views:

79

answers:

2

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... :(

+1  A: 

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);
Affe
What's the point in using a two-dimensional array? I mean... why.
Dan
Suppose it depends on your goal. If you're moving a checker, would you like to say, "It's at 1,1, legal moves are 2,2 and 2,0" or "It's at 9, legal moves are 16 and 18" I realize now that you're not actually using it as a gameboard, but if you plan to manipulate it at all after drawing it, it would probably still prove much easier to work with.
Affe
+1  A: 

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);
cHao
By dear... you just SOLVED it! That's logic thinking right there. I'm not good with Math since it's not my strong point... but THANK you. You got it! :-)
Dan