用图形制作棋盘样式(java applet)
好吧,我正在制作一个小程序,它可以绘制 32x32 方形图块(以制作地图),而我的问题是,当我希望它们按 8 × 8 排列时,它们会沿对角线排列(因此数组的形状为 8 × 8)。那么...我该如何解决这个问题?
谢谢。无论如何,由于代码 bbcode 是一个混蛋...这是 Pastebin URL :-)
http:// /www.danflow.pastebin.com/kAUEpg1E
这是问题:
我想要 8 x 8...:(
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... :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题是这一行:
为了将其绘制为 8x8,您可能需要将其更改为类似
The problem is this line:
In order to draw it 8x8, you'll probably want to change it to something like
就在这里:
g.drawImage(theTile, 32*i,32*i, this);
因此,在元素上,当 i = 2 时,您可以告诉它“两个出,两个下”。第三个元素打印“三出,三下”。我不知道为什么你不使用二维数组,但为了让它与一维数组一起工作,我想你可以这样做: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: