Wall generation

This commit is contained in:
Anuken
2020-02-17 20:33:01 -05:00
parent e215772f30
commit da2cc292c3
18 changed files with 123 additions and 40 deletions

View File

@@ -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()){

View File

@@ -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();
}

View File

@@ -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);
}
}