[英]Positioning of Polygons in Slick2D
I try to create hexagons and place them on the opengl window. 我尝试创建六边形并将其放置在opengl窗口中。 I want to use them as a tiled-map.
我想将它们用作平铺地图。 My current code looks like this:
我当前的代码如下所示:
private Polygon generateTile(){
Polygon poly = new Polygon();
for(int i = 0; i < 6; ++i) {
poly.addPoint((float)Math.sin(i/6.0*2*Math.PI),
(float)Math.cos(i/6.0*2*Math.PI));
}
return poly;
}
private void generateTiles (){
Shape s;
Polygon p = generateTile();
for (int i = 0; i <= 2; i++) {
for (int j = 0; j <=10; j++) {
s=p.transform(Transform.createScaleTransform(Constants.TILE_SIZE, Constants.TILE_SIZE));
if (i%2==0) {
s.setLocation(s.getMaxX()*j*2, s.getMaxY()*i*2);
} else {
s.setLocation(s.getMaxX()*j*2+Constants.TILE_SIZE, s.getMaxY()*i*2);
}
tiles.add(s);
}
}
Window: 窗口:
The problem is that the row 2 should integrate under row 1. 问题在于,第2行应整合到第1行之下。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.