package shootergame.world.layer.layergen; import java.util.Random; import shootergame.Main; import shootergame.entity.Entity; import shootergame.entity.EntityBullet; import shootergame.entity.EntityZombie; import shootergame.init.Tiles; import shootergame.tiles.Tile; import shootergame.util.math.random.OpenSimplexNoise; import shootergame.util.math.random.RandomHelpers; import shootergame.util.math.range.Range2i; import shootergame.util.math.vec.Vec2d; import shootergame.util.math.vec.Vec2i; import shootergame.world.chunk.Chunk; import shootergame.world.layer.Layer; public class LayerGenEarth extends LayerGen { @Override public Chunk generateChunk(Layer layer, Random rand, Vec2i c_pos) { // Create the new chunk Chunk chunk = new Chunk(layer, c_pos, rand); // Get the noise generator OpenSimplexNoise noisegen_n = new OpenSimplexNoise(rand.nextLong()); // Loop over the layer dimensions and create land for(int x=0;x 0.9) chunk.setFrontTile(Tiles.TREE, pos); else if(rand.nextDouble() > 0.99) chunk.setFrontTile(Tiles.ROCK, pos); else chunk.setFrontTile(Tiles.VOID, pos); // Terrain generation if(noise_n < 20) { chunk.setFrontTile(Tiles.WATER, pos); chunk.setBackTile(Tiles.DIRT, pos); } else if(noise_n < 60) chunk.setBackTile(Tiles.GRASS, pos); else if(noise_n < 80) chunk.setBackTile(Tiles.DIRT, pos); else chunk.setBackTile(Tiles.STONE, pos); } } // Send back the new chunk return chunk; } @Override public void spawnEntities(Layer layer, Random rand) { if(rand.nextDouble() > 0.99) { Entity zombie = new EntityZombie(); zombie.pos = new Vec2d( RandomHelpers.randrange(rand, (int)Main.player.pos.x - 100, (int)Main.player.pos.x + 100), RandomHelpers.randrange(rand, (int)Main.player.pos.y - 100, (int)Main.player.pos.y + 100)); layer.spawnEntity(zombie); } } }