Update map chunk generation

pull/33/head
Tobias Springer 4 years ago
parent 386725000a
commit 4566b620df

@ -158,37 +158,32 @@ export class MapChunk {
let weights = {}; let weights = {};
if (distanceToOriginInChunks < 3) { // Later there is a mix of everything
// In the beginning, there are just circles weights = {
weights = { [enumSubShape.rect]: 100,
[enumSubShape.circle]: 100, [enumSubShape.circle]: Math_round(50 + clamp(distanceToOriginInChunks * 2, 0, 50)),
}; [enumSubShape.star]: Math_round(20 + clamp(distanceToOriginInChunks * 2, 0, 30)),
} else if (distanceToOriginInChunks < 6) { [enumSubShape.windmill]: Math_round(5 + clamp(distanceToOriginInChunks * 2, 0, 20)),
// Later there come rectangles };
if (Math_random() > 0.4) {
weights = { if (distanceToOriginInChunks < 7) {
[enumSubShape.circle]: 100, // Initial chunk patches always have the same shape
}; const subShape = this.internalGenerateRandomSubShape(weights);
} else { subShapes = [subShape, subShape, subShape, subShape];
weights = { } else if (distanceToOriginInChunks < 12) {
[enumSubShape.rect]: 100, // Later patches can also have mixed ones
}; const subShapeA = this.internalGenerateRandomSubShape(weights);
} const subShapeB = this.internalGenerateRandomSubShape(weights);
subShapes = [subShapeA, subShapeA, subShapeB, subShapeB];
} else { } else {
// Finally there is a mix of everything // Finally there is a mix of everything
weights = { subShapes = [
[enumSubShape.rect]: 100, this.internalGenerateRandomSubShape(weights),
[enumSubShape.circle]: Math_round(50 + clamp(distanceToOriginInChunks * 2, 0, 50)), this.internalGenerateRandomSubShape(weights),
[enumSubShape.star]: Math_round(20 + clamp(distanceToOriginInChunks * 2, 0, 30)), this.internalGenerateRandomSubShape(weights),
[enumSubShape.windmill]: Math_round(5 + clamp(distanceToOriginInChunks * 2, 0, 20)), this.internalGenerateRandomSubShape(weights),
}; ];
} }
subShapes = [
this.internalGenerateRandomSubShape(weights),
this.internalGenerateRandomSubShape(weights),
this.internalGenerateRandomSubShape(weights),
this.internalGenerateRandomSubShape(weights),
];
const definition = this.root.shapeDefinitionMgr.getDefinitionFromSimpleShapes(subShapes); const definition = this.root.shapeDefinitionMgr.getDefinitionFromSimpleShapes(subShapes);
this.internalGeneratePatch(shapePatchSize, new ShapeItem(definition)); this.internalGeneratePatch(shapePatchSize, new ShapeItem(definition));

Loading…
Cancel
Save