2014-05-19 4 views
1

나는 육각형을 만들고 그것을 OpenGL 창에 놓으려고합니다. 타일 ​​맵으로 사용하고 싶습니다. 나의 현재 코드는 다음과 같습니다Slick2D에서 폴리곤의 위치 지정

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

      } 
     } 

창 :

enter image description here

문제는 행 2 타일의 오프셋 (offset) 1.

답변

2

실제이 행 아래에 통합해야한다는 것입니다 그것의 크기가 아니다.

here

Hex Grid dimensions

에 큰 기사가있다