レンダリング方法 (openGL、swing/awt、その他) は、マップ自体とは関係ありません。それがレンダリングされる方法です。私が書いた特別な CoordinateMap クラスを使用していますが、基本的にはMap<Point,MapTile>
.
マップをどのようにしたいかは、ここで何をしようとしているのかに大きな影響を与えます。ほとんどのアルゴリズムは次のようなものを使用すると思います(長方形を想定):
for(int x = minx; x <= maxx; x++) {
for(int y = miny; y <= maxy; y++) {
map.put(new Point(x,y),generateRandomTile());
}
}
できるもう 1 つのオプションは、拡散です。それはこのように動作します:
// pick 10 random points (10 is up to you)
MapTile[] seeds = new MapTile[10];
Point[] seedPoints = new Point[seeds.length];
for(int i = 0; i < seeds.length; i++) {
seeds[i] = generateRandomTile();
seedPoints[i] = generateRandomPoint();
}
int distance = 1;
while(true) {
boolean changed = false;
for(int i = 0; i < seedsPoints.length; i++) {
Point p = seedPoints[i];
for(int x = -distance; x <= distance; x++) {
Point here = new Point(x,p.y));
MapTile tile = tiles.get(here);
if(tile == null) {
tiles.put(here,new Tile(seeds[i].terrainType));
changed = true;
}
}
// that does the left edge of the square of distance away from
// the center. I'll leave the other edges of the square for you since they're boilerplate
} // end for seeds
if(!changed) break;
distance++;
}