Java でゲームのアイソメマップを作成しようとしていますが、これを行う方法が見つかりません。各位置JLabel
に使用できるように、アイソメ マップのポリゴンごとに を追加する必要があります。描画するポリゴンごとpaint()
に を追加するにはどうすればよいですか? JLabel
わかりません。次のような等角図の各位置を描画するアルゴリズムが既にあります。
//L is the width of the map (that will be the framw width)
//N will be the number of COLUMN, like N*N will be the total number of positions.
//The first position (a,b) that will be
a=L / (2*N+1)
b=a . tan(30º
for (int y = 0; y < N; y++) {
if (y % 2 == 0) { // Se y é PAR
for (int x = 0; x < N; x++) {
Polygon p = new Polygon();
p.addPoint(x * a * 2 + a, y * b);
p.addPoint(x * a * 2 + 2 * a, y * b + b);
p.addPoint(x * a * 2 + a, y * b + 2 * b);
p.addPoint(x * a * 2, y * b + b);
g.drawPolygon(p);
}
} else { // if Y is odd
for (int x = 0; x < N; x++) {
Polygon p = new Polygon();
p.addPoint(x * a * 2 + 2 * a, y * b);
p.addPoint(x * a * 2 + 3 * a, y * b + b);
p.addPoint(x * a * 2 + 2 * a, y * b + 2 * b);
p.addPoint(x * a * 2 + a, y * b + b);
g.drawPolygon(p);
}
}
}
よろしくお願いします