2012-05-08 4 views
0

아이소 메트릭 게임을 만들고 있으며 지그재그 아이소 메트릭 맵을 만들었습니다. 내 원래 생각은 다이아몬드 모양 이었지만 그렇게 할 수 없습니다.아이소 메트릭 맵 드로잉, 생성

다이아몬드 : coobird.net/img/tile-diamond-good-order.png

지그재그은 : 는 coobird.net/img/tile-zigzag-compact.png 여기

조금이다

세계 :

public void chunkGenerate() { 
    moduleX = ((ListManager.getTileWidth()*8)); 
    moduleY = ((ListManager.getTileHeight()*8)); 
    for (int x = 0; x <= width; x++) { 
     for (int y = 0; y <= height; y++) { 
      if ((x%moduleX) == 0) { 
       if ((y%moduleY) == 0) { 
        chunkList.add(new Chunk(x,y)); 
       } 
      } 
     } 
    } 
      } 

덩어리 :

내 코드의 당신은 무슨 일이 일어나고 있는지 보여3210
public void Generate() { 
    for (int x = 0; x < 8; x++) { 
     for (int y = 0;y< 8; y++) { 
      tileList.add(new Tile(location.getX()+(x*ListManager.getTileWidth()),location.getY()+(y*ListManager.getTileHeight()),0)); 
     } 
    } 
} 

렌더링 :

 for (Chunk c : w.getChunkList()) { 
      g2d = (Graphics2D) g.create(); 
      for (int i = 0; i<c.getTileList().size(); i+=2) { 
       g2d.drawImage(test2, (c.getTileList().get(i).getLocation().getX()+c.getTileList().get(i).getOffset().getxOffset()), (c.getTileList().get(i).getLocation().getY()+c.getTileList().get(i).getOffset().getyOffset()+w.getvOffset()), this); 
       g2d.drawImage(test2, (c.getTileList().get(i).getLocation().getX()), (c.getTileList().get(i).getLocation().getY()+w.getvOffset()), this); 
      } 
      for (int i = 1;i<c.getTileList().size(); i+=2) { 
       g2d.drawImage(test2, (c.getTileList().get(i).getLocation().getX()), (c.getTileList().get(i).getLocation().getY()+w.getvOffset()), this); 
       g2d.drawImage(test2, (c.getTileList().get(i).getLocation().getX()+c.getTileList().get(i).getOffset().getxOffset()), (c.getTileList().get(i).getLocation().getY()+c.getTileList().get(i).getOffset().getyOffset()+w.getvOffset()), this); 

      } 
     } 

내가 대신 지그재그의 다이아몬드로지도를 만들기로 도움이 필요합니다. 코드에 대한 추가 정보가 필요하면 아래에 설명하십시오. 또한이 코드의 버그 중 하나는 타일 몇 개마다 1 픽셀 폭의 공간이 있다는 것입니다. 내가 오프셋을 조정하려하는 이유 .. 내가 .. 도움이되지 않았다, 현재 오프셋을 모르는 : 나는 공백이없는에 도착 (타일 생성자)

offset = new IsometricOffset(21,11); 

가장 가까운 20,10했지만 여전히 있었다 도움을

http://img845.imageshack.us/img845/6242/picbz.png

감사 : 작은 공간

여기

는 그림입니다! 편집 : 화면의 타일 중 2 개가 실제 엔진의 타일 1 개에 불과합니다. 나는 그것을 고치기 위해 노력하고있다.

편집 :

을 변경하고있어이 : img526.imageshack.us/img526/3121/test333.png

도면 :

 for (Chunk c : w.getChunkList()) { 
      /*for (int i = 0; i<c.getTileList().size(); i++) { 
       g2d.drawImage(test2, (c.getTileList().get(i).getLocation().getX()), (c.getTileList().get(i).getLocation().getY()+w.getvOffset()), this); 
      }*/ 
      for (int i = 0;i<c.getTileList().size(); i++) { 
       g2d.drawImage(test2, (c.getTileList().get(i).getLocation().getX()+c.getTileList().get(i).getOffset().getxOffset()), (c.getTileList().get(i).getLocation().getY()+c.getTileList().get(i).getOffset().getyOffset()+w.getvOffset()), this); 

      } 
     } 

는 (필자는 오프셋없이 그리기 시도 그것은 그림과 같은 것을 그렸습니다.) 생성 :

for (int x = 0; x < 8; x++) { 
     for (int y = 0;y< 8; y++) { 
      tileList.add(new Tile(location.getX()+(x*ListManager.getTileWidth()/2),location.getY()+(y*ListManager.getTileHeight()/2),0)); 
     } 
     location.setX(location.getX()+ListManager.getTileWidth()/2); 
     location.setY(location.getY()+ListManager.getTileHeight()/2); 
    } 
실험 후3210

는 :

는 생성 :

 public void Generate() { 
    for (int x = 0; x < 8; ++x) { 
     for (int y = 0;y< 8; ++y) { 
      tileList.add(new Tile(location.getX()+(y*ListManager.getTileWidth()/2),location.getY()-(y*ListManager.getTileHeight()/2),0)); 
     } 
     location.setX(location.getX()+ListManager.getTileHeight()/2); 
     location.setY(location.getY()+ListManager.getTileWidth()/2); 
    } 
} 

결과 : http://img814.imageshack.us/img814/3450/bombombom.png

+0

당신이 더 많은 정보를 필요로하는 경우 그것은 도움이하지만 난 ... – Trixmix

답변

1

봅니다지도가 45도 회전 상상 : 이것은 내가 가진 가장 가까운 것입니다.

   (0, 3) 
     (0, 2)  (1, 2) 
(0, 1)  (1, 1)  (2, 2) 
     (1, 0)  (2, 1) 
       (2, 0) 

그리고 렌더링주기는 그렇게해야합니다 :

x = 0, y = 100, 
for (dx = 0; dx < 3; ++dx) { 
    for (dy = 0; dy < 3; ++dy) { 
     drawTile(x + dy * width/2, y - dy * height/2); 
    } 
    x += width/2; 
    y += height/2; 
} 

UPD : 작업의 증거.

코드 (ActionScript는하지만, 알고리즘의 차이가 없음) :

var x:Number = 100, y:Number = 100, 
    dx:Number, dy:Number, px:Number, py:Number, 
    halfWidth:Number = 40, halfHeight:Number = 20, 
    s:Sprite = new Sprite(), 
    g:Graphics = s.graphics; 

g.lineStyle(1, 0xffffff); 
for (dx = 0; dx < 3; ++dx) { 
    for (dy = 0; dy < 3; ++dy) { 
     px = x + dy * halfWidth; 
     py = y - dy * halfHeight; 

     g.moveTo(px - halfWidth , py); 
     g.lineTo(px, py - halfHeight); 
     g.lineTo(px + halfWidth, py); 
     g.lineTo(px, py + halfHeight); 
     g.lineTo(px - halfWidth, py); 
    } 
    x += halfWidth; 
    y += halfHeight; 
} 

addChild(s); 

결과 :

good looking tiles

+0

을 말해 있어요 : http://img526.imageshack.us/img526/3121/test333.png 다음은 내가 변경 한 코드 중 일부입니다 : 스레드에 게시 된 – Trixmix

+0

내가 편집 한 것처럼 drawTile의 첫 번째 인수를 변경하려고합니다. – Yarg

+0

http://img812.imageshack.us/img812/9945/asddsd.png - 결과 – Trixmix

관련 문제