mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-03-15 03:11:07 -07:00
Testing more procedural generation
This commit is contained in:
parent
daccfa5fe3
commit
98a53381fb
5 changed files with 62 additions and 6 deletions
|
|
@ -123,7 +123,6 @@ public class WaveSpawner{
|
|||
|
||||
//hide spawnpoints, they have served their purpose
|
||||
world.tile(x, y).setBlock(Blocks.air);
|
||||
Log.info("Add spawn " + x + " " + y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@ package io.anuke.mindustry.content;
|
|||
|
||||
import io.anuke.mindustry.game.ContentList;
|
||||
import io.anuke.mindustry.game.Rules;
|
||||
import io.anuke.mindustry.maps.generators.DesertWastesGenerator;
|
||||
import io.anuke.mindustry.maps.zonegen.DesertWastesGenerator;
|
||||
import io.anuke.mindustry.maps.generators.MapGenerator;
|
||||
import io.anuke.mindustry.maps.generators.MapGenerator.Decoration;
|
||||
import io.anuke.mindustry.maps.zonegen.OvergrowthGenerator;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
|
||||
|
|
@ -45,6 +46,19 @@ public class Zones implements ContentList{
|
|||
}};
|
||||
}};
|
||||
|
||||
overgrowth = new Zone("overgrowth", new OvergrowthGenerator(320, 320)){{
|
||||
startingItems = ItemStack.list(Items.copper, 200);
|
||||
conditionWave = 10;
|
||||
zoneRequirements = ZoneRequirement.with(groundZero, 10);
|
||||
blockRequirements = new Block[]{Blocks.router};
|
||||
resources = new Item[]{Items.copper, Items.lead, Items.coal};
|
||||
rules = () -> new Rules(){{
|
||||
waves = true;
|
||||
waveTimer = true;
|
||||
waveSpacing = 60 * 60 * 1.5f;
|
||||
}};
|
||||
}};
|
||||
|
||||
craters = new Zone("craters", new MapGenerator("craters", 1).dist(0).decor(new Decoration(Blocks.snow, Blocks.sporeCluster, 0.01))){{
|
||||
startingItems = ItemStack.list(Items.copper, 200);
|
||||
conditionWave = 10;
|
||||
|
|
|
|||
|
|
@ -49,9 +49,9 @@ public abstract class BasicGenerator extends RandomGenerator{
|
|||
});
|
||||
}
|
||||
|
||||
public void terrain(Tile[][] tiles, Block dst, float mag, float cmag){
|
||||
public void terrain(Tile[][] tiles, Block dst, float scl, float mag, float cmag){
|
||||
pass(tiles, (x, y) -> {
|
||||
double rocks = sim.octaveNoise2D(5, 0.5, 1f / 60f, x, y) * mag
|
||||
double rocks = sim.octaveNoise2D(5, 0.5, 1f / scl, x, y) * mag
|
||||
+ Mathf.dst((float)x / width, (float)y / height, 0.5f, 0.5f) * cmag;
|
||||
|
||||
double edgeDist = Math.min(x, Math.min(y, Math.min(Math.abs(x - (width - 1)), Math.abs(y - (height - 1)))));
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
package io.anuke.mindustry.maps.generators;
|
||||
package io.anuke.mindustry.maps.zonegen;
|
||||
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.mindustry.content.Blocks;
|
||||
import io.anuke.mindustry.maps.generators.BasicGenerator;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
|
||||
public class DesertWastesGenerator extends BasicGenerator{
|
||||
|
|
@ -18,7 +19,7 @@ public class DesertWastesGenerator extends BasicGenerator{
|
|||
@Override
|
||||
public void decorate(Tile[][] tiles){
|
||||
ores(tiles);
|
||||
terrain(tiles, Blocks.sandRocks, 1.5f, 0.9f);
|
||||
terrain(tiles, Blocks.sandRocks, 60f, 1.5f, 0.9f);
|
||||
|
||||
int rand = 40;
|
||||
int border = 25;
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
package io.anuke.mindustry.maps.zonegen;
|
||||
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.mindustry.content.Blocks;
|
||||
import io.anuke.mindustry.maps.generators.BasicGenerator;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
|
||||
public class OvergrowthGenerator extends BasicGenerator{
|
||||
|
||||
public OvergrowthGenerator(int width, int height){
|
||||
super(width, height, Blocks.oreCopper, Blocks.oreLead, Blocks.oreCoal, Blocks.oreCopper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(int x, int y){
|
||||
floor = Blocks.moss;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decorate(Tile[][] tiles){
|
||||
ores(tiles);
|
||||
terrain(tiles, Blocks.sporePine, 70f, 1.4f, 1f);
|
||||
|
||||
int rand = 40;
|
||||
int border = 25;
|
||||
int spawnX = Mathf.clamp(30 + Mathf.range(rand), border, width - border), spawnY = Mathf.clamp(30 + Mathf.range(rand), border, height - border);
|
||||
int endX = Mathf.clamp(width - 30 + Mathf.range(rand), border, width - border), endY = Mathf.clamp(height - 30 + Mathf.range(rand), border, height - border);
|
||||
|
||||
brush(tiles, pathfind(tiles, spawnX, spawnY, endX, endY, tile -> (tile.solid() ? 5f : 0f) + (float)sim.octaveNoise2D(1, 1, 1f / 50f, tile.x, tile.y) * 50, manhattan), 6);
|
||||
brush(tiles, pathfind(tiles, spawnX, spawnY, endX, endY, tile -> (tile.solid() ? 4f : 0f) + (float)sim.octaveNoise2D(1, 1, 1f / 90f, tile.x+999, tile.y) * 70, manhattan), 5);
|
||||
|
||||
erase(tiles, endX, endY, 10);
|
||||
erase(tiles, spawnX, spawnY, 20);
|
||||
distort(tiles, 20f, 4f);
|
||||
inverseFloodFill(tiles, tiles[spawnX][spawnY], Blocks.sporerocks);
|
||||
|
||||
noise(tiles, Blocks.darksandTaintedWater, Blocks.duneRocks, 4, 0.7f, 120f, 0.64f);
|
||||
|
||||
tiles[endX][endY].setBlock(Blocks.spawn);
|
||||
loadout.setup(spawnX, spawnY);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue