Fixed lighting, lava caves, harder enemies, stronger upgrades.
This commit is contained in:
parent
b672a176b8
commit
54b6262813
1120
hs_err_pid31967.log
1120
hs_err_pid31967.log
File diff suppressed because it is too large
Load Diff
1119
hs_err_pid613.log
1119
hs_err_pid613.log
File diff suppressed because it is too large
Load Diff
1120
hs_err_pid675.log
1120
hs_err_pid675.log
File diff suppressed because it is too large
Load Diff
1120
hs_err_pid713.log
1120
hs_err_pid713.log
File diff suppressed because it is too large
Load Diff
1120
hs_err_pid792.log
1120
hs_err_pid792.log
File diff suppressed because it is too large
Load Diff
1121
hs_err_pid832.log
1121
hs_err_pid832.log
File diff suppressed because it is too large
Load Diff
1147
hs_err_pid982.log
1147
hs_err_pid982.log
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 86 KiB |
Binary file not shown.
|
|
@ -75,7 +75,7 @@ public class DisplayRender
|
||||||
0.0f, 1.0f, 0.0f);
|
0.0f, 1.0f, 0.0f);
|
||||||
|
|
||||||
EntityPlayer player = Main.player;
|
EntityPlayer player = Main.player;
|
||||||
Camera camera = new Camera(new Vec3d(player.pos.x, player.pos.y, 0), new Vec2d(player.angle, 45), 10, 2);
|
Camera camera = new Camera(new Vec3d(player.pos.x, player.pos.y, 0), new Vec2d(player.angle, 45), 10, 1);
|
||||||
Camera.camera = camera;
|
Camera.camera = camera;
|
||||||
|
|
||||||
//GlHelpers.translate(0, 0, -5);
|
//GlHelpers.translate(0, 0, -5);
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ public class DisplayRenderUI
|
||||||
|
|
||||||
// Disable some opengl options
|
// Disable some opengl options
|
||||||
GlHelpers.disableDepthTest();
|
GlHelpers.disableDepthTest();
|
||||||
|
GlHelpers.color4(1, 1, 1, 1);
|
||||||
|
|
||||||
// Get some text settings
|
// Get some text settings
|
||||||
Vec2d text_size = new Vec2d(0.5, 0.2);
|
Vec2d text_size = new Vec2d(0.5, 0.2);
|
||||||
|
|
|
||||||
|
|
@ -8,32 +8,50 @@ import shootergame.util.math.MathHelpers;
|
||||||
import shootergame.util.math.TileState;
|
import shootergame.util.math.TileState;
|
||||||
import shootergame.util.math.vec.Vec2i;
|
import shootergame.util.math.vec.Vec2i;
|
||||||
import shootergame.world.chunk.Chunk;
|
import shootergame.world.chunk.Chunk;
|
||||||
|
import shootergame.world.chunk.ChunkEventHandler;
|
||||||
import shootergame.world.layer.Layer;
|
import shootergame.world.layer.Layer;
|
||||||
|
|
||||||
public class LightingManager
|
public class LightingManager
|
||||||
{
|
{
|
||||||
public static void update()
|
public static void update()
|
||||||
{
|
{
|
||||||
|
if(!ChunkEventHandler.loaded) return;
|
||||||
int r = Camera.camera.renderDistance;
|
int r = Camera.camera.renderDistance;
|
||||||
Layer layer = Main.world.getLayer();
|
Layer layer = Main.world.getLayer();
|
||||||
double light_clear = layer.layergen.getLightLevel();
|
double light_clear = layer.layergen.getLightLevel();
|
||||||
EntityPlayer player = Main.player;
|
EntityPlayer player = Main.player;
|
||||||
|
|
||||||
// Loop over all the loaded blocks and reset the light level
|
// Clear every light source
|
||||||
for(int x=-r*16;x<r*16;x++) {
|
for(int cx=-r;cx<=r;cx++) {
|
||||||
for(int y=-r*16;y<r*16;y++) {
|
for(int cy=-r;cy<=r;cy++)
|
||||||
Vec2i pos = new Vec2i(x + (int)player.pos.x, y + (int)player.pos.y);
|
{
|
||||||
layer.setLightLevel(light_clear, pos);
|
// Get the chunk position and the chunk
|
||||||
|
Chunk chunk = layer.chunks.get(new Vec2i(
|
||||||
|
MathHelpers.floor(player.pos.x / 16) + cx,
|
||||||
|
MathHelpers.floor(player.pos.y / 16) + cy));
|
||||||
|
|
||||||
|
// Loop over all the tiles
|
||||||
|
for(int x=0;x<16;x++) {
|
||||||
|
for(int y=0;y<16;y++)
|
||||||
|
{
|
||||||
|
// Clear the tiles light
|
||||||
|
chunk.setLightLevel(light_clear, new Vec2i(x, y));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop over every entity to scan for light sources
|
// Loop over every entity and every block to scan for light sources
|
||||||
for(int cx=-r;cx<r;cx++) {
|
for(int cx=-r;cx<=r;cx++) {
|
||||||
for(int cy=-r;cy<r;cy++)
|
for(int cy=-r;cy<=r;cy++)
|
||||||
{
|
{
|
||||||
// Loop over all the entities
|
// Loop over all the entities
|
||||||
Vec2i cpos = new Vec2i(cx + ((int)player.pos.x / 16), cy + ((int)player.pos.y / 16));
|
Vec2i cpos = new Vec2i(
|
||||||
Chunk chunk = layer.getChunk(cpos);
|
cx + MathHelpers.floor(player.pos.x / 16),
|
||||||
|
cy + MathHelpers.floor(player.pos.y / 16));
|
||||||
|
Chunk chunk = layer.chunks.get(cpos);
|
||||||
|
|
||||||
|
// Create all the entity light sources
|
||||||
for(Entity e : chunk.entities)
|
for(Entity e : chunk.entities)
|
||||||
{
|
{
|
||||||
// Does this entity emit light
|
// Does this entity emit light
|
||||||
|
|
@ -47,7 +65,7 @@ public class LightingManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop over all the tiles
|
// Create all the tile light sources
|
||||||
for(int x=0;x<16;x++) {
|
for(int x=0;x<16;x++) {
|
||||||
for(int y=0;y<16;y++)
|
for(int y=0;y<16;y++)
|
||||||
{
|
{
|
||||||
|
|
@ -64,14 +82,12 @@ public class LightingManager
|
||||||
{
|
{
|
||||||
// Calculate the light given off by the tile
|
// Calculate the light given off by the tile
|
||||||
double light_tile = chunk.getLightLevel(tid);
|
double light_tile = chunk.getLightLevel(tid);
|
||||||
double light_tile2 = light_tile;
|
double light_tile_old = light_tile;
|
||||||
double ftsl = fts.tile.getLightLevel(fts);
|
light_tile = MathHelpers.biggest(light_tile, fts.tile.getLightLevel(fts));
|
||||||
double btsl = fts.tile.getLightLevel(bts);
|
light_tile = MathHelpers.biggest(light_tile, fts.tile.getLightLevel(bts));
|
||||||
if(ftsl > light_tile) light_tile = ftsl;
|
|
||||||
if(btsl > light_tile) light_tile = btsl;
|
|
||||||
|
|
||||||
// Has the light level changed; add light to this tile
|
// Has the light level changed; add light to this tile
|
||||||
if(light_tile != light_tile2) {
|
if(light_tile != light_tile_old) {
|
||||||
addLightToTiles(layer, tpos, light_tile, true);
|
addLightToTiles(layer, tpos, light_tile, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -91,6 +107,14 @@ public class LightingManager
|
||||||
|
|
||||||
private static void addLightToTiles(Layer layer, Vec2i lpos, double light, boolean ignoreDissipation)
|
private static void addLightToTiles(Layer layer, Vec2i lpos, double light, boolean ignoreDissipation)
|
||||||
{
|
{
|
||||||
|
if(
|
||||||
|
MathHelpers.floor(lpos.squareDistance(new Vec2i(
|
||||||
|
MathHelpers.floor(Main.player.pos.x),
|
||||||
|
MathHelpers.floor(Main.player.pos.y))) / 16)
|
||||||
|
> Camera.camera.renderDistance) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the light pos id
|
// Get the light pos id
|
||||||
int lid = lpos.getId(Chunk.CHUNK_SIZE);
|
int lid = lpos.getId(Chunk.CHUNK_SIZE);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,13 @@ import shootergame.world.layer.Layer;
|
||||||
|
|
||||||
public class EntityZombie extends EntityVertical implements EntityAlive
|
public class EntityZombie extends EntityVertical implements EntityAlive
|
||||||
{
|
{
|
||||||
private OpenSimplexNoise noise_movement;
|
protected OpenSimplexNoise noise_movement;
|
||||||
private OpenSimplexNoise noise_gun_fire;
|
protected OpenSimplexNoise noise_gun_fire;
|
||||||
private OpenSimplexNoise noise_gun_angle;
|
protected OpenSimplexNoise noise_gun_angle;
|
||||||
private double time;
|
protected double time;
|
||||||
private double health_max = 100;
|
protected double health_max = 100;
|
||||||
private double health = health_max;
|
protected double health = health_max;
|
||||||
private int gun_interval = 0;
|
protected int gun_interval = 0;
|
||||||
|
|
||||||
public EntityZombie() {
|
public EntityZombie() {
|
||||||
super(Textures.ENTITY_ZOMBIE, new Vec2d(1, 1));
|
super(Textures.ENTITY_ZOMBIE, new Vec2d(1, 1));
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
package shootergame.entity;
|
||||||
|
|
||||||
|
import shootergame.display.Camera;
|
||||||
|
import shootergame.init.Textures;
|
||||||
|
import shootergame.util.gl.texture.TextureReference;
|
||||||
|
import shootergame.util.math.vec.Vec2d;
|
||||||
|
|
||||||
|
public class EntityZombieArmored extends EntityZombie
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
public EntityZombieArmored() {
|
||||||
|
this.health_max *= 5;
|
||||||
|
this.gun_interval *= 2;
|
||||||
|
this.health = this.health_max;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(Vec2d pos, Camera camera, TextureReference tex, Vec2d size) {
|
||||||
|
super.render(pos, camera, Textures.ENTITY_ZOMBIE_ARMORED, new Vec2d(1, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,107 +0,0 @@
|
||||||
package shootergame.entity;
|
|
||||||
|
|
||||||
import shootergame.Main;
|
|
||||||
import shootergame.init.Textures;
|
|
||||||
import shootergame.util.math.random.OpenSimplexNoise;
|
|
||||||
import shootergame.util.math.vec.Vec2d;
|
|
||||||
import shootergame.world.chunk.Chunk;
|
|
||||||
import shootergame.world.layer.Layer;
|
|
||||||
|
|
||||||
public class EntityZombieBomber extends EntityVertical implements EntityAlive
|
|
||||||
{
|
|
||||||
private int time = 0;
|
|
||||||
private OpenSimplexNoise noise_movement;
|
|
||||||
private double health = 100;
|
|
||||||
private double max_health = 100;
|
|
||||||
|
|
||||||
public EntityZombieBomber(Vec2d pos) {
|
|
||||||
super(Textures.ENTITY_ZOMBIE_BOMBER, new Vec2d(1, 1));
|
|
||||||
|
|
||||||
this.noise_movement = new OpenSimplexNoise(rand.nextLong());
|
|
||||||
this.pos = pos;
|
|
||||||
|
|
||||||
this.goThroughSolid = false;
|
|
||||||
this.crossUnWalkable = false;
|
|
||||||
this.isSolid = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void explode(Layer layer)
|
|
||||||
{
|
|
||||||
kill();
|
|
||||||
layer.spawnEntity(new EntityExplosion(pos, 6, 5000));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void moveBackward() {
|
|
||||||
super.moveBackward(0.06);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void moveForward() {
|
|
||||||
super.moveForward(0.06);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void tick(Chunk chunk, Layer layer) {
|
|
||||||
super.tick(chunk, layer);
|
|
||||||
|
|
||||||
// Explode if the zombie is dead
|
|
||||||
if(health <= 0) {
|
|
||||||
this.explode(layer);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the angle between the player and the zombie
|
|
||||||
double angle = Math.atan2(pos.x - Main.player.pos.x, pos.y - Main.player.pos.y);
|
|
||||||
|
|
||||||
// Move forward towards the player
|
|
||||||
this.angle = Math.toDegrees(angle) + 180;
|
|
||||||
this.angle += noise_movement.eval(time, 0)*80;
|
|
||||||
this.moveForward();
|
|
||||||
|
|
||||||
// Explode if the zombie is in radius of the player
|
|
||||||
if(Main.player.pos.squareDistance(pos) < 3) {
|
|
||||||
this.explode(layer);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Increase time
|
|
||||||
time += 0.001;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addHealth(double amount) {
|
|
||||||
this.health += amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeHealth(double amount) {
|
|
||||||
this.health -= amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getHealth() {
|
|
||||||
return health;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void resetHealth() {
|
|
||||||
this.health = max_health;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clearHealth() {
|
|
||||||
this.health = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double maxHealth() {
|
|
||||||
return max_health;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setHealth(double health) {
|
|
||||||
this.health = health;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -83,7 +83,7 @@ public class Textures
|
||||||
);
|
);
|
||||||
|
|
||||||
// Zombie Bomber
|
// Zombie Bomber
|
||||||
public static final TextureReference ENTITY_ZOMBIE_BOMBER = new AnimationReference(10,
|
public static final TextureReference ENTITY_ZOMBIE_ARMORED = new AnimationReference(10,
|
||||||
texmap.getTextureReference(2, 3, 15, 16),
|
texmap.getTextureReference(2, 3, 15, 16),
|
||||||
texmap.getTextureReference(3, 4, 15, 16),
|
texmap.getTextureReference(3, 4, 15, 16),
|
||||||
texmap.getTextureReference(4, 5, 15, 16),
|
texmap.getTextureReference(4, 5, 15, 16),
|
||||||
|
|
@ -111,7 +111,7 @@ public class Textures
|
||||||
);
|
);
|
||||||
|
|
||||||
// Lava
|
// Lava
|
||||||
public static final TextureReference TILE_LAVA = new AnimationReference(20,
|
public static final TextureReference TILE_LAVA = new AnimationReference(50,
|
||||||
texmap.getTextureReference(0, 1, 6, 7),
|
texmap.getTextureReference(0, 1, 6, 7),
|
||||||
texmap.getTextureReference(1, 2, 6, 7),
|
texmap.getTextureReference(1, 2, 6, 7),
|
||||||
texmap.getTextureReference(2, 3, 6, 7),
|
texmap.getTextureReference(2, 3, 6, 7),
|
||||||
|
|
@ -131,7 +131,7 @@ public class Textures
|
||||||
);
|
);
|
||||||
|
|
||||||
// Water flow
|
// Water flow
|
||||||
public static final TextureReference TILE_WATER_FLOW = new AnimationReference(20,
|
public static final TextureReference TILE_WATER_FLOW = new AnimationReference(10,
|
||||||
texmap.getTextureReference(0, 1, 9, 10),
|
texmap.getTextureReference(0, 1, 9, 10),
|
||||||
texmap.getTextureReference(1, 2, 9, 10),
|
texmap.getTextureReference(1, 2, 9, 10),
|
||||||
texmap.getTextureReference(2, 3, 9, 10),
|
texmap.getTextureReference(2, 3, 9, 10),
|
||||||
|
|
@ -151,7 +151,7 @@ public class Textures
|
||||||
);
|
);
|
||||||
|
|
||||||
// Lava flow
|
// Lava flow
|
||||||
public static final TextureReference TILE_LAVA_FLOW = new AnimationReference(10,
|
public static final TextureReference TILE_LAVA_FLOW = new AnimationReference(50,
|
||||||
texmap.getTextureReference(0, 1, 7, 8),
|
texmap.getTextureReference(0, 1, 7, 8),
|
||||||
texmap.getTextureReference(1, 2, 7, 8),
|
texmap.getTextureReference(1, 2, 7, 8),
|
||||||
texmap.getTextureReference(2, 3, 7, 8),
|
texmap.getTextureReference(2, 3, 7, 8),
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,13 @@ import shootergame.time.GameTimer;
|
||||||
import shootergame.util.math.MathHelpers;
|
import shootergame.util.math.MathHelpers;
|
||||||
import shootergame.util.math.random.OpenSimplexNoise;
|
import shootergame.util.math.random.OpenSimplexNoise;
|
||||||
|
|
||||||
public class LavaLightlevel
|
class LavaLightlevel
|
||||||
{
|
{
|
||||||
static OpenSimplexNoise noise = new OpenSimplexNoise(new Random().nextLong());
|
static OpenSimplexNoise noise = new OpenSimplexNoise(new Random().nextLong());
|
||||||
|
|
||||||
static double getLightLevel() {
|
static double getLightLevel() {
|
||||||
return MathHelpers.map(noise.eval(GameTimer.getTime() / 1000.0, 0), -1, 1, 0.4, 0.6);
|
double v = MathHelpers.map(noise.eval(GameTimer.getTime() / 512.0, 0), -1, 1, 0.6, 0.8);
|
||||||
|
//System.out.println("v = "+v);
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@ import shootergame.world.layer.Layer;
|
||||||
|
|
||||||
public class TileChest extends TileVertical
|
public class TileChest extends TileVertical
|
||||||
{
|
{
|
||||||
public static final short CHEST_CAVES = 0;
|
public static final short CHEST_CAVES = 1;
|
||||||
|
public static final short CHEST_LAVA_CAVES = 2;
|
||||||
|
|
||||||
public TileChest(String id) {
|
public TileChest(String id) {
|
||||||
super(id, Textures.TILE_CHEST, new Vec2d(1, 1));
|
super(id, Textures.TILE_CHEST, new Vec2d(1, 1));
|
||||||
|
|
@ -67,6 +68,34 @@ public class TileChest extends TileVertical
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(state.meta == CHEST_LAVA_CAVES)
|
||||||
|
{
|
||||||
|
// Ammo
|
||||||
|
spawnItem(chunk, tpos, new ItemStack(Items.AMMO, RandomHelpers.randrange(rand, 250), (short)1));
|
||||||
|
|
||||||
|
// Tnt
|
||||||
|
spawnItem(chunk, tpos, new ItemStack(Items.TNT, RandomHelpers.randrange(rand, 2), (short)10));
|
||||||
|
|
||||||
|
// Health potions
|
||||||
|
spawnItem(chunk, tpos, new ItemStack(Items.HEALTH_POTION, RandomHelpers.randrange(rand, 4), (short)50));
|
||||||
|
|
||||||
|
// Gun upgrade
|
||||||
|
if(RandomHelpers.randrange(rand, 5) == 0) {
|
||||||
|
spawnItem(chunk, tpos, new ItemStack(Items.GUN_UPGRADE, 1, (short)3));
|
||||||
|
}
|
||||||
|
if(RandomHelpers.randrange(rand, 20) == 0) {
|
||||||
|
spawnItem(chunk, tpos, new ItemStack(Items.GUN_UPGRADE, 1, (short)4));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Defence upgrade
|
||||||
|
if(RandomHelpers.randrange(rand, 20) == 0) {
|
||||||
|
spawnItem(chunk, tpos, new ItemStack(Items.DEFENCE_UPGRADE, 1, (short)3));
|
||||||
|
}
|
||||||
|
if(RandomHelpers.randrange(rand, 5) == 0) {
|
||||||
|
spawnItem(chunk, tpos, new ItemStack(Items.DEFENCE_UPGRADE, 1, (short)4));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
layer.breakFrontTile(tpos);
|
layer.breakFrontTile(tpos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ public class TileWall extends TileFlat
|
||||||
this.tileSolid = true;
|
this.tileSolid = true;
|
||||||
this.tileHitbox = 1;
|
this.tileHitbox = 1;
|
||||||
|
|
||||||
this.light_dissipation = 1;
|
this.light_dissipation = 1/2.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package shootergame.time;
|
package shootergame.time;
|
||||||
|
|
||||||
import mainloop.task.IMainloopTask;
|
import mainloop.task.IMainloopTask;
|
||||||
|
import shootergame.Main;
|
||||||
|
|
||||||
public class GameTimer implements IMainloopTask
|
public class GameTimer implements IMainloopTask
|
||||||
{
|
{
|
||||||
|
|
@ -23,6 +24,8 @@ public class GameTimer implements IMainloopTask
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void MainLoopUpdate() {
|
public void MainLoopUpdate() {
|
||||||
|
if(!Main.game_paused) {
|
||||||
time += 1;
|
time += 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,12 +36,13 @@ public class Layer
|
||||||
public void render(Camera camera)
|
public void render(Camera camera)
|
||||||
{
|
{
|
||||||
// Render every chunk in the players render distance
|
// Render every chunk in the players render distance
|
||||||
for(int x=-camera.renderDistance;x<camera.renderDistance;x++) {
|
int r = camera.renderDistance;
|
||||||
for(int y=-camera.renderDistance;y<camera.renderDistance;y++)
|
for(int x=-r;x<=r;x++) {
|
||||||
|
for(int y=-r;y<=r;y++)
|
||||||
{
|
{
|
||||||
// Get the chunk x and y
|
// Get the chunk x and y
|
||||||
int cx = ((int)Main.player.pos.x / 16) + x;
|
int cx = MathHelpers.floor(Main.player.pos.x / 16) + x;
|
||||||
int cy = ((int)Main.player.pos.y / 16) + y;
|
int cy = MathHelpers.floor(Main.player.pos.y / 16) + y;
|
||||||
|
|
||||||
// Render the chunk
|
// Render the chunk
|
||||||
chunks.get(new Vec2i(cx, cy)).render(camera);
|
chunks.get(new Vec2i(cx, cy)).render(camera);
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,9 @@ import java.util.Random;
|
||||||
import shootergame.Main;
|
import shootergame.Main;
|
||||||
import shootergame.entity.Entity;
|
import shootergame.entity.Entity;
|
||||||
import shootergame.entity.EntityZombie;
|
import shootergame.entity.EntityZombie;
|
||||||
import shootergame.entity.EntityZombieBomber;
|
import shootergame.entity.EntityZombieArmored;
|
||||||
import shootergame.init.Tiles;
|
import shootergame.init.Tiles;
|
||||||
|
import shootergame.util.math.MathHelpers;
|
||||||
import shootergame.util.math.TileState;
|
import shootergame.util.math.TileState;
|
||||||
import shootergame.util.math.random.OpenSimplexNoise;
|
import shootergame.util.math.random.OpenSimplexNoise;
|
||||||
import shootergame.util.math.random.RandomHelpers;
|
import shootergame.util.math.random.RandomHelpers;
|
||||||
|
|
@ -47,10 +48,10 @@ public class LayerGenCaves extends LayerGen
|
||||||
int cy = y + c_pos.y * Chunk.CHUNK_SIZE.my;
|
int cy = y + c_pos.y * Chunk.CHUNK_SIZE.my;
|
||||||
|
|
||||||
// Get the noise value and the position vector
|
// Get the noise value and the position vector
|
||||||
double noise_n = (noisegen_n.eval(cx/10.0, cy/10.0) + 1) * 50;
|
double noise_n = 100 - MathHelpers.positive( noisegen_n.eval(cx/20.0, cy/20.0) * 100 );
|
||||||
Vec2i pos = new Vec2i(x, y);
|
Vec2i pos = new Vec2i(x, y);
|
||||||
|
|
||||||
if(noise_n > 60) {
|
if(noise_n > 90) {
|
||||||
chunk.setBackTile(Tiles.STONE.getDefaultState(), pos);
|
chunk.setBackTile(Tiles.STONE.getDefaultState(), pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,7 +76,7 @@ public class LayerGenCaves extends LayerGen
|
||||||
|
|
||||||
// Only place a chest here if the tile is clear
|
// Only place a chest here if the tile is clear
|
||||||
if(chunk.getBackTile(chest_pos).tile == getTileDestroyed().tile) {
|
if(chunk.getBackTile(chest_pos).tile == getTileDestroyed().tile) {
|
||||||
chunk.setFrontTile(Tiles.TILE_CHEST.getDefaultState(), chest_pos);
|
chunk.setFrontTile(new TileState(Tiles.TILE_CHEST, 1), chest_pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,7 +96,7 @@ public class LayerGenCaves extends LayerGen
|
||||||
layer.spawnEntity(zombie);
|
layer.spawnEntity(zombie);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rand.nextDouble() > 0.98)
|
/*if(rand.nextDouble() > 0.98)
|
||||||
{
|
{
|
||||||
Entity zombie = new EntityZombieBomber(new Vec2d(
|
Entity zombie = new EntityZombieBomber(new Vec2d(
|
||||||
RandomHelpers.randrange(rand, (int)Main.player.pos.x - 128, (int)Main.player.pos.x + 128),
|
RandomHelpers.randrange(rand, (int)Main.player.pos.x - 128, (int)Main.player.pos.x + 128),
|
||||||
|
|
@ -105,7 +106,7 @@ public class LayerGenCaves extends LayerGen
|
||||||
(int)zombie.pos.y)).tile == getTileDestroyed().tile &&
|
(int)zombie.pos.y)).tile == getTileDestroyed().tile &&
|
||||||
zombie.pos.squareDistance(Main.player.pos) > 32)
|
zombie.pos.squareDistance(Main.player.pos) > 32)
|
||||||
layer.spawnEntity(zombie);
|
layer.spawnEntity(zombie);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,15 @@ package shootergame.world.layer.layergen;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import shootergame.Main;
|
||||||
|
import shootergame.entity.Entity;
|
||||||
|
import shootergame.entity.EntityZombie;
|
||||||
|
import shootergame.entity.EntityZombieArmored;
|
||||||
import shootergame.init.Tiles;
|
import shootergame.init.Tiles;
|
||||||
import shootergame.util.math.TileState;
|
import shootergame.util.math.TileState;
|
||||||
import shootergame.util.math.random.OpenSimplexNoise;
|
import shootergame.util.math.random.OpenSimplexNoise;
|
||||||
import shootergame.util.math.random.RandomHelpers;
|
import shootergame.util.math.random.RandomHelpers;
|
||||||
|
import shootergame.util.math.vec.Vec2d;
|
||||||
import shootergame.util.math.vec.Vec2i;
|
import shootergame.util.math.vec.Vec2i;
|
||||||
import shootergame.world.chunk.Chunk;
|
import shootergame.world.chunk.Chunk;
|
||||||
import shootergame.world.layer.Layer;
|
import shootergame.world.layer.Layer;
|
||||||
|
|
@ -42,18 +47,26 @@ public class LayerGenLavaCaves extends LayerGen
|
||||||
int cy = y + pos.y * Chunk.CHUNK_SIZE.my;
|
int cy = y + pos.y * Chunk.CHUNK_SIZE.my;
|
||||||
|
|
||||||
// Get the noise value and the position vector
|
// Get the noise value and the position vector
|
||||||
double noise_n = (noisegen_n.eval(cx/10.0, cy/10.0) + 1) * 50;
|
double noise_n = (noisegen_n.eval(cx/100.0, cy/100.0) + 1) * 50;
|
||||||
|
double noise_c = (noisegen_n.eval(cx/20.0, cy/20.0) + 1) * 50;
|
||||||
Vec2i tpos = new Vec2i(x, y);
|
Vec2i tpos = new Vec2i(x, y);
|
||||||
|
|
||||||
if(noise_n > 40) {
|
if(noise_n > 60 || noise_n < 20) {
|
||||||
|
chunk.setBackTile(Tiles.STONE.getDefaultState(), tpos);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(noise_c > 40 && noise_c < 60) {
|
||||||
chunk.setBackTile(Tiles.STONE.getDefaultState(), tpos);
|
chunk.setBackTile(Tiles.STONE.getDefaultState(), tpos);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
chunk.setBackTile(Tiles.WALL.getDefaultState(), tpos);
|
chunk.setBackTile(Tiles.WALL.getDefaultState(), tpos);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(noise_n > 55 && noise_n < 60) {
|
if(noise_n > 58 && noise_n < 60 && noise_c > 40 && noise_c < 60) {
|
||||||
chunk.setFrontTile(Tiles.LAVA_FLOW.getDefaultState(), tpos);
|
chunk.setFrontTile(Tiles.LAVA_FLOW.getDefaultState(), tpos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -66,11 +79,44 @@ public class LayerGenLavaCaves extends LayerGen
|
||||||
if(hasLadder) {
|
if(hasLadder) {
|
||||||
chunk.setFrontTile(new TileState(Tiles.LADDER_UP, (short)1), ladder_pos);
|
chunk.setFrontTile(new TileState(Tiles.LADDER_UP, (short)1), ladder_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vec2i chest_pos = new Vec2i(
|
||||||
|
RandomHelpers.randrange(rand, Chunk.CHUNK_SIZE.mx),
|
||||||
|
RandomHelpers.randrange(rand, Chunk.CHUNK_SIZE.my));
|
||||||
|
Vec2i lava_flow_pos = new Vec2i(
|
||||||
|
RandomHelpers.randrange(rand, Chunk.CHUNK_SIZE.mx),
|
||||||
|
RandomHelpers.randrange(rand, Chunk.CHUNK_SIZE.my));
|
||||||
|
|
||||||
|
// Only place a chest here if the tile is clear
|
||||||
|
if(chunk.getBackTile(chest_pos).tile == getTileDestroyed().tile) {
|
||||||
|
chunk.setFrontTile(new TileState(Tiles.TILE_CHEST, 2), chest_pos);
|
||||||
|
}
|
||||||
|
if(chunk.getBackTile(lava_flow_pos).tile == getTileDestroyed().tile) {
|
||||||
|
chunk.setFrontTile(Tiles.LAVA_FLOW.getDefaultState(), lava_flow_pos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawnEntities(Layer layer, Random rand) {
|
public void spawnEntities(Layer layer, Random rand)
|
||||||
|
{
|
||||||
|
if(rand.nextDouble() > 0.95)
|
||||||
|
{
|
||||||
|
Entity zombie = new EntityZombieArmored();
|
||||||
|
zombie.pos = new Vec2d(
|
||||||
|
RandomHelpers.randrange(rand, (int)Main.player.pos.x - 128, (int)Main.player.pos.x + 128),
|
||||||
|
RandomHelpers.randrange(rand, (int)Main.player.pos.y - 128, (int)Main.player.pos.y + 128));
|
||||||
|
|
||||||
|
TileState tsb = layer.getBackTile(new Vec2i((int)zombie.pos.x,
|
||||||
|
(int)zombie.pos.y));
|
||||||
|
TileState tsf = layer.getFrontTile(new Vec2i((int)zombie.pos.x,
|
||||||
|
(int)zombie.pos.y));
|
||||||
|
if(
|
||||||
|
tsb.tile == getTileDestroyed().tile &&
|
||||||
|
tsf.tile == Tiles.VOID &&
|
||||||
|
zombie.pos.squareDistance(Main.player.pos) > 32) {
|
||||||
|
layer.spawnEntity(zombie);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue