mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-17 13:53:57 -07:00
Add diskArea rmgen helper function and use it instead of Math.PI * Math.pow(radius, 2).
Use getMapArea instead of mapSize*mapSize. This was SVN commit r20332.
This commit is contained in:
parent
1dee1eced9
commit
1a896f531a
13 changed files with 22 additions and 17 deletions
|
|
@ -65,7 +65,7 @@ InitMap();
|
|||
|
||||
const numPlayers = getNumPlayers();
|
||||
const mapSize = getMapSize();
|
||||
const mapArea = mapSize*mapSize;
|
||||
const mapArea = getMapArea();
|
||||
|
||||
var clPlayer = createTileClass();
|
||||
var clHill = createTileClass();
|
||||
|
|
@ -299,7 +299,7 @@ while (possibleEdges.length)
|
|||
|
||||
for (let [x, z] of [[ix, iz], [ix2, iz2]])
|
||||
createArea(
|
||||
new ClumpPlacer(Math.floor(Math.PI * Math.pow(scaleByMapSize(9, 15) / 2, 2)), 0.95, 0.6, 10, x, z),
|
||||
new ClumpPlacer(Math.floor(diskArea(scaleByMapSize(4.5, 7.5))), 0.95, 0.6, 10, x, z),
|
||||
[
|
||||
new LayeredPainter([tCliff, tPrimary], [3]),
|
||||
new SmoothElevationPainter(ELEVATION_SET, 30, 2),
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ createArea(
|
|||
log("Creating small puddles at the map border to ensure players being separated...");
|
||||
for (let [x, z] of [[riverX1, riverZ1], [riverX2, riverZ2]])
|
||||
createArea(
|
||||
new ClumpPlacer(Math.floor(Math.PI * Math.pow(riverWidth / 2, 2)), 0.95, 0.6, 10, x, z),
|
||||
new ClumpPlacer(Math.floor(diskArea(riverWidth / 2)), 0.95, 0.6, 10, x, z),
|
||||
new SmoothElevationPainter(ELEVATION_SET, waterHeight, 4),
|
||||
null);
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ function createCycladicArchipelagoIsland(ix, iz, tileClass, radius, coralRadius)
|
|||
{
|
||||
log("Creating deep ocean rocks...");
|
||||
createArea(
|
||||
new ClumpPlacer(Math.PI * Math.pow(radius + coralRadius, 2), 0.7, 0.1, 10, ix, iz),
|
||||
new ClumpPlacer(diskArea(radius + coralRadius), 0.7, 0.1, 10, ix, iz),
|
||||
[
|
||||
new LayeredPainter([tOceanRockDeep, tOceanCoral], [5]),
|
||||
paintClass(clCoral)
|
||||
|
|
@ -91,7 +91,7 @@ function createCycladicArchipelagoIsland(ix, iz, tileClass, radius, coralRadius)
|
|||
log("Creating island...");
|
||||
areas.push(
|
||||
createArea(
|
||||
new ClumpPlacer(Math.PI * Math.pow(radius, 2), 0.7, 0.1, 10, ix, iz),
|
||||
new ClumpPlacer(diskArea(radius), 0.7, 0.1, 10, ix, iz),
|
||||
[
|
||||
new LayeredPainter([tOceanCoral, tBeachWet, tBeachDry, tBeach, tBeachBlend, tGrass], [1, 3, 1, 1, 2]),
|
||||
new SmoothElevationPainter(ELEVATION_SET, 3, 5),
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ InitMap();
|
|||
|
||||
const numPlayers = getNumPlayers();
|
||||
const mapSize = getMapSize();
|
||||
const mapArea = mapSize*mapSize;
|
||||
const mapArea = getMapArea();
|
||||
|
||||
var clPlayer = createTileClass();
|
||||
var clHill = createTileClass();
|
||||
|
|
@ -242,7 +242,7 @@ createArea(
|
|||
|
||||
log("Creating hill on the central island...");
|
||||
createArea(
|
||||
new ClumpPlacer(Math.pow(scaleByMapSize(6, 18), 2) * 22, 1, 1, 10, center, center),
|
||||
new ClumpPlacer(diskArea(scaleByMapSize(6, 18)) * 7, 1, 1, 10, center, center),
|
||||
new SmoothElevationPainter(ELEVATION_SET, 20, 8),
|
||||
null);
|
||||
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ createArea(
|
|||
log("Creating small puddles at the map border to ensure players being separated...");
|
||||
for (let [fx, fz] of [river1, river2])
|
||||
createArea(
|
||||
new ClumpPlacer(Math.floor(Math.PI * Math.pow(scaleByMapSize(5, 10), 2)), 0.95, 0.6, 10, fx, fz),
|
||||
new ClumpPlacer(Math.floor(diskArea(scaleByMapSize(5, 10))), 0.95, 0.6, 10, fx, fz),
|
||||
new SmoothElevationPainter(ELEVATION_SET, waterHeight, 2),
|
||||
avoidClasses(clPlayer, 8));
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ InitMap();
|
|||
|
||||
const numPlayers = getNumPlayers();
|
||||
const mapSize = getMapSize();
|
||||
const mapArea = mapSize*mapSize;
|
||||
const mapArea = getMapArea();
|
||||
|
||||
var clPlayer = createTileClass();
|
||||
var clHill = createTileClass();
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ RMS.SetProgress(25);
|
|||
log("Creating oasis...");
|
||||
var oRadius = scaleByMapSize(14, 40);
|
||||
createArea(
|
||||
new ClumpPlacer(Math.PI * Math.pow(oRadius, 2), 0.6, 0.15, 0, mapSize/2, mapSize/2),
|
||||
new ClumpPlacer(diskArea(oRadius), 0.6, 0.15, 0, mapSize / 2, mapSize / 2),
|
||||
[
|
||||
new LayeredPainter([[tSand, pForest], [tGrassSand25, pForestOasis], tGrassSand25, tShore, tWaterDeep], [2, 3, 1, 1]),
|
||||
new SmoothElevationPainter(ELEVATION_MODIFY, -11, 8),
|
||||
|
|
|
|||
|
|
@ -470,7 +470,7 @@ var OceanX = fractionToTiles(0.5) + cos(MoutainAngle + lololo)*fractionToTiles(0
|
|||
var OceanZ = fractionToTiles(0.5) + sin(MoutainAngle + lololo)*fractionToTiles(0.48);
|
||||
|
||||
createArea(
|
||||
new ClumpPlacer(Math.PI * Math.pow(fractionToTiles(0.18), 2), 0.9, 0.05, 10, OceanX, OceanZ),
|
||||
new ClumpPlacer(diskArea(fractionToTiles(0.18)), 0.9, 0.05, 10, OceanX, OceanZ),
|
||||
[
|
||||
paintClass(clWater),
|
||||
new ElevationPainter(-22)
|
||||
|
|
@ -481,7 +481,7 @@ OceanX = fractionToTiles(0.5) + cos(PI + MoutainAngle + lololo)*fractionToTiles(
|
|||
OceanZ = fractionToTiles(0.5) + sin(PI + MoutainAngle + lololo)*fractionToTiles(0.48);
|
||||
|
||||
createArea(
|
||||
new ClumpPlacer(Math.PI * Math.pow(fractionToTiles(0.18), 2), 0.9, 0.05, 10, OceanX, OceanZ),
|
||||
new ClumpPlacer(diskArea(fractionToTiles(0.18)), 0.9, 0.05, 10, OceanX, OceanZ),
|
||||
[
|
||||
new ElevationPainter(-22),
|
||||
paintClass(clWater)
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ InitMap();
|
|||
|
||||
const numPlayers = getNumPlayers();
|
||||
const mapSize = getMapSize();
|
||||
const mapArea = mapSize*mapSize;
|
||||
const mapArea = getMapArea();
|
||||
|
||||
var clPlayer = createTileClass();
|
||||
var clHill = createTileClass();
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
function diskArea(radius)
|
||||
{
|
||||
return Math.PI * Math.square(radius);
|
||||
}
|
||||
|
||||
function rotateCoordinates(x, z, angle, centerX = 0.5, centerZ = 0.5)
|
||||
{
|
||||
let sin = Math.sin(angle);
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ RMS.SetProgress(30);
|
|||
log("Creating oases...");
|
||||
for (let i = 0; i < numPlayers; ++i)
|
||||
createArea(
|
||||
new ClumpPlacer(Math.PI * Math.pow(scaleByMapSize(16, 60), 2) * 0.185,
|
||||
new ClumpPlacer(diskArea(scaleByMapSize(16, 60)) * 0.185,
|
||||
0.6,
|
||||
0.15,
|
||||
0,
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ for (var m = 0; m < numPlayers; m++)
|
|||
|
||||
createArea(
|
||||
new ClumpPlacer(
|
||||
Math.floor(Math.PI * Math.pow(scaleByMapSize(10, 50), 2) / 3),
|
||||
Math.floor(diskArea(scaleByMapSize(10, 50)) / 3),
|
||||
0.95,
|
||||
0.6,
|
||||
10,
|
||||
|
|
@ -170,7 +170,7 @@ for (var m = 0; m < numPlayers; m++)
|
|||
|
||||
createArea(
|
||||
new ClumpPlacer(
|
||||
Math.floor(Math.PI * Math.pow(scaleByMapSize(10, 50), 2) / 5),
|
||||
Math.floor(diskArea(scaleByMapSize(10, 50)) / 5),
|
||||
0.95,
|
||||
0.6,
|
||||
10,
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ function initIsConnected()
|
|||
|
||||
function createIsland(islandID, size, tileClass)
|
||||
{
|
||||
let hillSize = Math.PI * Math.pow(playerIslandRadius, 2) * size;
|
||||
let hillSize = diskArea(playerIslandRadius) * size;
|
||||
createArea(
|
||||
new ClumpPlacer(hillSize, 0.95, 0.6, 10, islandX[islandID], islandZ[islandID]),
|
||||
[
|
||||
|
|
|
|||
Loading…
Reference in a new issue