Wall generation
This commit is contained in:
@@ -182,7 +182,7 @@ public abstract class BasicGenerator extends RandomGenerator{
|
||||
Tile end = tiles.getn(endX, endY);
|
||||
GridBits closed = new GridBits(width, height);
|
||||
IntFloatMap costs = new IntFloatMap();
|
||||
PriorityQueue<Tile> queue = new PriorityQueue<>(tiles.width() * tiles.height()/4, (a, b) -> Float.compare(costs.get(a.pos(), 0f) + dh.cost(a.x, a.y, end.x, end.y), costs.get(b.pos(), 0f) + dh.cost(b.x, b.y, end.x, end.y)));
|
||||
PriorityQueue<Tile> queue = new PriorityQueue<>(tiles.width * tiles.height /4, (a, b) -> Float.compare(costs.get(a.pos(), 0f) + dh.cost(a.x, a.y, end.x, end.y), costs.get(b.pos(), 0f) + dh.cost(b.x, b.y, end.x, end.y)));
|
||||
queue.add(start);
|
||||
boolean found = false;
|
||||
while(!queue.isEmpty()){
|
||||
|
||||
@@ -62,7 +62,7 @@ public class MapGenerator extends Generator{
|
||||
for(Tile tile : tiles){
|
||||
if(tile.overlay() == Blocks.spawn){
|
||||
int rad = 10;
|
||||
Geometry.circle(tile.x, tile.y, tiles.width(), tiles.height(), rad, (wx, wy) -> {
|
||||
Geometry.circle(tile.x, tile.y, tiles.width, tiles.height, rad, (wx, wy) -> {
|
||||
if(tile.overlay().itemDrop != null){
|
||||
tile.clearOverlay();
|
||||
}
|
||||
|
||||
@@ -20,11 +20,14 @@ public abstract class RandomGenerator extends Generator{
|
||||
public void generate(Tiles tiles){
|
||||
for(int x = 0; x < width; x++){
|
||||
for(int y = 0; y < height; y++){
|
||||
floor = Blocks.air;
|
||||
block = Blocks.air;
|
||||
ore = Blocks.air;
|
||||
Tile prev = tiles.getn(x, y);
|
||||
floor = prev.floor();
|
||||
block = prev.block();
|
||||
ore = prev.overlay();
|
||||
generate(x, y);
|
||||
tiles.set(x, y, new Tile(x, y, floor, ore, block));
|
||||
prev.setFloor(floor.asFloor());
|
||||
prev.setBlock(block);
|
||||
prev.setOverlay(ore);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user