Generation tweaks
This commit is contained in:
@@ -158,10 +158,7 @@ public class MinimapRenderer implements Disposable{
|
||||
if(tile == null) return 0;
|
||||
tile = tile.link();
|
||||
int bc = tile.block().minimapColor(tile);
|
||||
if(bc != 0){
|
||||
return bc;
|
||||
}
|
||||
Color color = Tmp.c1.set(MapIO.colorFor(tile.floor(), tile.block(), tile.overlay(), tile.team()));
|
||||
Color color = Tmp.c1.set(bc == 0 ? MapIO.colorFor(tile.floor(), tile.block(), tile.overlay(), tile.team()) : bc);
|
||||
color.mul(1f - Mathf.clamp(world.getDarkness(tile.x, tile.y) / 4f));
|
||||
|
||||
return color.rgba();
|
||||
|
||||
@@ -45,13 +45,44 @@ public abstract class BasicGenerator implements WorldGenerator{
|
||||
|
||||
}
|
||||
|
||||
//for visual testing only
|
||||
public void cliffs2(){
|
||||
for(Tile tile : tiles){
|
||||
tile.setBlock(Blocks.air);
|
||||
tile.cost = tile.floor().isLiquid ? 0 : (byte)(sim.octaveNoise2D(4, 0.5, 1.0 / 90.0, tile.x, tile.y) * 5);
|
||||
}
|
||||
|
||||
for(Tile tile : tiles){
|
||||
if(tile.floor().isLiquid) continue;
|
||||
|
||||
int rotation = 0;
|
||||
for(int i = 0; i < 8; i++){
|
||||
Tile other = tiles.get(tile.x + Geometry.d8[i].x, tile.y + Geometry.d8[i].y);
|
||||
if(other != null && other.cost < tile.cost){ //down slope
|
||||
rotation |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
tile.rotation(rotation);
|
||||
}
|
||||
|
||||
for(Tile tile : tiles){
|
||||
if(tile.rotation() != 0){
|
||||
int rotation = tile.rotation();
|
||||
tile.setBlock(Blocks.cliff);
|
||||
tile.setOverlay(Blocks.air);
|
||||
tile.rotation(rotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void cliffs(){
|
||||
for(Tile tile : tiles){
|
||||
if(!tile.block().isStatic()) continue;
|
||||
|
||||
int rotation = 0;
|
||||
for(int i = 0; i < 4; i++){
|
||||
Tile other = tiles.get(tile.x + Geometry.d4[i].x, tile.y + Geometry.d4[i].y);
|
||||
for(int i = 0; i < 8; i++){
|
||||
Tile other = tiles.get(tile.x + Geometry.d8[i].x, tile.y + Geometry.d8[i].y);
|
||||
if(other != null && !other.block().isStatic()){
|
||||
rotation |= (1 << i);
|
||||
}
|
||||
|
||||
@@ -102,13 +102,34 @@ public class TestPlanetGenerator implements PlanetGenerator{
|
||||
@Override
|
||||
protected void generate(){
|
||||
|
||||
class Room{
|
||||
int x, y, radius;
|
||||
ObjectSet<Room> connected = new ObjectSet<>();
|
||||
|
||||
Room(int x, int y, int radius){
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.radius = radius;
|
||||
connected.add(this);
|
||||
}
|
||||
|
||||
void connect(Room to){
|
||||
if(connected.contains(to)) return;
|
||||
|
||||
connected.add(to);
|
||||
float nscl = Mathf.random(20f, 60f);
|
||||
int stroke = Mathf.random(4, 12);
|
||||
brush(pathfind(x, y, to.x, to.y, tile -> (tile.solid() ? 5f : 0f) + (float)sim.octaveNoise2D(1, 1, 1f / nscl, tile.x, tile.y) * 50, manhattan), stroke);
|
||||
}
|
||||
}
|
||||
|
||||
cells(4);
|
||||
distort(20f, 12f);
|
||||
|
||||
float constraint = 1.3f;
|
||||
float radius = width / 2f / Mathf.sqrt3;
|
||||
int rooms = Mathf.random(2, 5);
|
||||
Array<Point3> array = new Array<>();
|
||||
Array<Room> array = new Array<>();
|
||||
|
||||
//TODO replace random calls with seed
|
||||
|
||||
@@ -118,32 +139,31 @@ public class TestPlanetGenerator implements PlanetGenerator{
|
||||
float ry = (height/2f + Tmp.v1.y);
|
||||
float maxrad = radius - Tmp.v1.len();
|
||||
float rrad = Math.min(Mathf.random(9f, maxrad / 2f), 30f);
|
||||
array.add(new Point3((int)rx, (int)ry, (int)rrad));
|
||||
array.add(new Room((int)rx, (int)ry, (int)rrad));
|
||||
}
|
||||
|
||||
for(Point3 room : array){
|
||||
erase(room.x, room.y, room.z);
|
||||
for(Room room : array){
|
||||
erase(room.x, room.y, room.radius);
|
||||
}
|
||||
|
||||
int connections = Mathf.random(Math.max(rooms - 1, 1), rooms + 3);
|
||||
Room spawn = array.random();
|
||||
for(int i = 0; i < connections; i++){
|
||||
Point3 from = array.random();
|
||||
Point3 to = array.random();
|
||||
array.random().connect(array.random());
|
||||
}
|
||||
|
||||
float nscl = Mathf.random(20f, 60f);
|
||||
int stroke = Mathf.random(4, 12);
|
||||
brush(pathfind(from.x, from.y, to.x, to.y, tile -> (tile.solid() ? 5f : 0f) + (float)sim.octaveNoise2D(1, 1, 1f / nscl, tile.x, tile.y) * 50, manhattan), stroke);
|
||||
for(Room room : array){
|
||||
spawn.connect(room);
|
||||
}
|
||||
|
||||
cells(1);
|
||||
distort(20f, 6f);
|
||||
|
||||
Point3 spawn = array.random();
|
||||
inverseFloodFill(tiles.getn(spawn.x, spawn.y));
|
||||
|
||||
ores(ores);
|
||||
|
||||
for(Point3 other : array){
|
||||
for(Room other : array){
|
||||
if(other != spawn){
|
||||
// tiles.getn(other.x, other.y).setOverlay(Blocks.spawn);
|
||||
}
|
||||
|
||||
@@ -19,13 +19,18 @@ public class Cliff extends Block{
|
||||
@Override
|
||||
public void draw(Tile tile){
|
||||
int r = tile.rotation();
|
||||
for(int i = 0; i < 4; i++){
|
||||
for(int i = 0; i < 8; i++){
|
||||
if((r & (1 << i)) != 0){
|
||||
Draw.color(Tmp.c1.set(tile.floor().color).mul(1.3f + (i >= 2 ? -0.4f : 0.3f)));
|
||||
Draw.rect(region, tile.worldx(), tile.worldy(), i * 90f);
|
||||
Draw.color(Tmp.c1.set(tile.floor().color).mul(1.3f + (i >= 4 ? -0.4f : 0.3f)));
|
||||
Draw.rect(region, tile.worldx(), tile.worldy(), 11f, 11f, i * 45f);
|
||||
}
|
||||
}
|
||||
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int minimapColor(Tile tile){
|
||||
return Tmp.c1.set(tile.floor().color).mul(1.2f).rgba();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user