Added wind, fixed some issues with particles
This commit is contained in:
parent
fe1f97f248
commit
135d6ef185
|
|
@ -41,6 +41,6 @@
|
|||
<classpathentry kind="lib" path="/home/josua/code/Java Libraries/lwjgl-3.2.2-lightweight/lwjgl-stb-natives-macos.jar"/>
|
||||
<classpathentry kind="lib" path="/home/josua/code/Java Libraries/lwjgl-3.2.2-lightweight/lwjgl-stb-natives-windows.jar"/>
|
||||
<classpathentry kind="lib" path="/home/josua/code/Java Libraries/lwjgl-3.2.2-lightweight/lwjgl-stb-sources.jar"/>
|
||||
<classpathentry kind="lib" path="/home/josua/code/Java Libraries/binary-data-format-v2.2.jar"/>
|
||||
<classpathentry kind="lib" path="/home/josua/code/Java Libraries/binary-data-format-v2.1.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
|||
|
|
@ -49,9 +49,6 @@ public class DisplayRender
|
|||
Matrix4 rotated = Matrix4.rotate(-camera.angle, 0, 1, 0);
|
||||
Matrix4 billboard = Matrix4.multiply(Matrix4.rotate(-45, 1, 0, 0), rotated);
|
||||
|
||||
// Process all the light sources
|
||||
//DynamicLighting.update();
|
||||
|
||||
Main.window.environmentRenderer.use();
|
||||
GL33.glUniformMatrix4fv(Main.window.glsl_billboard, true, billboard.getArray());
|
||||
GL33.glUniformMatrix4fv(Main.window.glsl_projection, true, projection.getArray());
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ public class DisplayRenderUI
|
|||
model_health_f.render();
|
||||
|
||||
double temperature = MathHelpers.smoothStep(Main.player.getTemperature());
|
||||
double hydration = MathHelpers.smoothStep(1 - Main.player.getHydration());
|
||||
double hydration = MathHelpers.smoothStep(1 - Main.player.getHydration()) * 0.75;
|
||||
|
||||
GL33.glUniform2f(Main.window.glsl_tex_cut, 0, 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import bdf.types.BdfObject;
|
|||
import gl_engine.MathHelpers;
|
||||
import gl_engine.vec.Vec2d;
|
||||
import gl_engine.vec.Vec3d;
|
||||
import projectzombie.entity.particle.ParticleSpark;
|
||||
import projectzombie.entity.particle.ParticleSmokeTrail;
|
||||
import projectzombie.init.Models;
|
||||
import projectzombie.model.Model;
|
||||
import projectzombie.world.chunk.Chunk;
|
||||
|
|
@ -17,17 +17,17 @@ public class EntityTnt extends Entity implements EntityHoldsEntities
|
|||
protected int explode_time;
|
||||
private int explode_radius;
|
||||
private double explode_damage;
|
||||
private ParticleSpark[] smoke_particles;
|
||||
private ParticleSmokeTrail smoke_particles;
|
||||
|
||||
@Override
|
||||
public Entity[] getEntities() {
|
||||
return smoke_particles;
|
||||
return new Entity[] {smoke_particles};
|
||||
}
|
||||
|
||||
public EntityTnt(BdfObject bdf) {
|
||||
super(bdf);
|
||||
|
||||
this.smoke_particles = new ParticleSpark[50];
|
||||
this.smoke_particles = new ParticleSmokeTrail(this, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -59,7 +59,7 @@ public class EntityTnt extends Entity implements EntityHoldsEntities
|
|||
velocity = velocity.add(new Vec3d(v.x, v.y, 0.01));
|
||||
this.explode_radius = explode_radius;
|
||||
this.explode_damage = explode_damage;
|
||||
this.smoke_particles = new ParticleSpark[100];
|
||||
this.smoke_particles = new ParticleSmokeTrail(this, 1);
|
||||
|
||||
// Set to 2.5 seconds
|
||||
this.explode_time = 250;
|
||||
|
|
@ -74,25 +74,13 @@ public class EntityTnt extends Entity implements EntityHoldsEntities
|
|||
public void tick(Chunk chunk, Layer layer) {
|
||||
super.tick(chunk, layer);
|
||||
|
||||
int dead_particle = 0;
|
||||
int dead_particle_count = 0;
|
||||
|
||||
for(int i=0;i<smoke_particles.length;i++)
|
||||
{
|
||||
ParticleSpark particle = smoke_particles[i];
|
||||
|
||||
if(particle == null || particle.isDead()) {
|
||||
dead_particle_count += 1;
|
||||
dead_particle = i;
|
||||
continue;
|
||||
}
|
||||
|
||||
particle.tick(chunk, layer);
|
||||
}
|
||||
smoke_particles.tick(chunk, layer);
|
||||
|
||||
if(!active)
|
||||
{
|
||||
if(dead_particle_count == smoke_particles.length - 1) {
|
||||
smoke_particles.stopParticles();
|
||||
|
||||
if(smoke_particles.noMoreParticles()) {
|
||||
kill();
|
||||
}
|
||||
|
||||
|
|
@ -105,8 +93,6 @@ public class EntityTnt extends Entity implements EntityHoldsEntities
|
|||
active = false;
|
||||
explode(layer);
|
||||
}
|
||||
|
||||
smoke_particles[dead_particle] = new ParticleSpark(getPos().add(new Vec3d(0, 1, 0)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import gl_engine.vec.Vec2i;
|
|||
import gl_engine.vec.Vec3d;
|
||||
import projectzombie.Main;
|
||||
import projectzombie.entity.EntityParticle;
|
||||
import projectzombie.init.Models;
|
||||
import projectzombie.model.IModel;
|
||||
import projectzombie.model.Model;
|
||||
import projectzombie.model.ModelVertical;
|
||||
|
|
@ -24,20 +25,22 @@ import projectzombie.world.layer.Layer;
|
|||
|
||||
public class ParticleBreak extends EntityParticle implements IModel
|
||||
{
|
||||
private static final Random rand = new Random();
|
||||
protected static final Random rand = new Random();
|
||||
|
||||
private class Break {
|
||||
protected class Break {
|
||||
TextureRef3D ref;
|
||||
Vec3d velocity;
|
||||
Vec3d pos;
|
||||
boolean moving;
|
||||
int flags;
|
||||
int time, flags;
|
||||
}
|
||||
|
||||
private Break[] particles;
|
||||
protected Break[] particles;
|
||||
private int ibo, vbo, vao;
|
||||
private boolean generated;
|
||||
private int dead, still, time;
|
||||
protected int dead, still, time;
|
||||
protected double still_ypos;
|
||||
protected boolean do_gravity;
|
||||
|
||||
public Vec2d getParticleSize() {
|
||||
return new Vec2d(0.1, 0.1);
|
||||
|
|
@ -51,8 +54,30 @@ public class ParticleBreak extends EntityParticle implements IModel
|
|||
this(pos, velocity, model, count, 0.05);
|
||||
}
|
||||
|
||||
protected Break createParticle(
|
||||
IModel model, TextureRef3D ref, int tex_id,
|
||||
Vec3d pos, Vec3d velocity, float[] verticies,
|
||||
double velocity_up_multiplier, double model_height, int i)
|
||||
{
|
||||
Break particle = new Break();
|
||||
|
||||
particle.pos = pos.add(new Vec3d(0, rand.nextDouble() * model_height, 0));
|
||||
particle.velocity = velocity.multiply(rand.nextDouble()).add(
|
||||
MathHelpers.moveTowards2(0.01, rand.nextDouble() * MathHelpers.TWO_PI).xny().add(
|
||||
new Vec3d(0, rand.nextDouble() * velocity_up_multiplier, 0)));
|
||||
particle.ref = ref;
|
||||
particle.moving = true;
|
||||
particle.flags = ((int)verticies[tex_id * Model.SIZE + Model.SIZE - 1] & 0b0110) | 0b1000;
|
||||
|
||||
return particle;
|
||||
}
|
||||
|
||||
protected ParticleBreak(Vec3d pos, Vec3d velocity, IModel model, int count, double velocity_up_multiplier) {
|
||||
super(pos, new Vec3d(0, 0, 0));
|
||||
super(new Vec3d(pos.x, 0, pos.z), new Vec3d(0, 0, 0));
|
||||
|
||||
if(pos.squareDistance(Main.player.getPos()) > 32) {
|
||||
count = 0;
|
||||
}
|
||||
|
||||
this.hasGravity = false;
|
||||
|
||||
|
|
@ -65,8 +90,6 @@ public class ParticleBreak extends EntityParticle implements IModel
|
|||
|
||||
for(int i=0;i<particles.length;i++)
|
||||
{
|
||||
Break particle = new Break();
|
||||
|
||||
int tex_id = (int)(rand.nextDouble() * textures.length);
|
||||
TextureRef3D texture = textures[tex_id];
|
||||
TextureRef3D ref = new TextureRef3D();
|
||||
|
|
@ -84,42 +107,64 @@ public class ParticleBreak extends EntityParticle implements IModel
|
|||
ref.texmap = texture.texmap;
|
||||
ref.z = texture.z;
|
||||
|
||||
particle.pos = pos.add(new Vec3d(0, rand.nextDouble() * model_height, 0));
|
||||
particle.velocity = velocity.multiply(rand.nextDouble()).add(
|
||||
MathHelpers.moveTowards2(0.01, rand.nextDouble() * MathHelpers.TWO_PI).xny().add(
|
||||
new Vec3d(0, rand.nextDouble() * velocity_up_multiplier, 0)));
|
||||
particle.ref = ref;
|
||||
particle.moving = true;
|
||||
particle.flags = (int)verticies[tex_id * Model.SIZE + Model.SIZE - 1] | 0b1000;
|
||||
Break particle = createParticle(
|
||||
model, ref, tex_id, pos, velocity,
|
||||
verticies, velocity_up_multiplier,
|
||||
model_height, i);
|
||||
|
||||
particles[i] = particle;
|
||||
}
|
||||
|
||||
time = 1000;
|
||||
generated = false;
|
||||
do_gravity = true;
|
||||
still = 0;
|
||||
dead = 0;
|
||||
}
|
||||
|
||||
protected void onAllStill() {
|
||||
if(time < 0 && rand.nextDouble() > 0.75) {
|
||||
dead += 1;
|
||||
}
|
||||
}
|
||||
|
||||
protected void onAllDead() {
|
||||
if(getPos().squareDistance(Main.player.getPos()) > 32) {
|
||||
kill();
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isStill(Break particle) {
|
||||
return particle.pos.y < 0;
|
||||
}
|
||||
|
||||
protected void onStill(Break particle) {
|
||||
particle.moving = false;
|
||||
particle.pos.y = still_ypos;
|
||||
still += 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(Chunk chunk, Layer layer) {
|
||||
super.tick(chunk, layer);
|
||||
|
||||
if(isDead()) {
|
||||
return;
|
||||
}
|
||||
|
||||
time -= 1;
|
||||
|
||||
if(dead == particles.length - 1) {
|
||||
kill();
|
||||
onAllDead();
|
||||
return;
|
||||
}
|
||||
|
||||
if(time < 0 && still == particles.length) {
|
||||
if(rand.nextDouble() > 0.75) {
|
||||
dead += 1;
|
||||
}
|
||||
if(still == particles.length) {
|
||||
onAllStill();
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i=0;i<particles.length;i++)
|
||||
for(int i=0;i<(particles.length - dead);i++)
|
||||
{
|
||||
Break particle = particles[i];
|
||||
|
||||
|
|
@ -127,14 +172,15 @@ public class ParticleBreak extends EntityParticle implements IModel
|
|||
continue;
|
||||
}
|
||||
|
||||
if(particle.pos.y < 0) {
|
||||
particle.moving = false;
|
||||
particle.pos.y = 0;
|
||||
still += 1;
|
||||
if(isStill(particle)) {
|
||||
onStill(particle);
|
||||
continue;
|
||||
}
|
||||
|
||||
particle.velocity.y -= MathHelpers.FallSpeed;
|
||||
if(do_gravity) {
|
||||
particle.velocity.y -= MathHelpers.FallSpeed;
|
||||
}
|
||||
|
||||
particle.pos = particle.pos.add(particle.velocity);
|
||||
}
|
||||
}
|
||||
|
|
@ -146,7 +192,12 @@ public class ParticleBreak extends EntityParticle implements IModel
|
|||
}
|
||||
|
||||
@Override
|
||||
public IModel getModel() {
|
||||
public IModel getModel()
|
||||
{
|
||||
if(isDead()) {
|
||||
return Models.EMPTY;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -181,7 +232,7 @@ public class ParticleBreak extends EntityParticle implements IModel
|
|||
float x = (float)getParticleSize().x/2;
|
||||
float y = (float)getParticleSize().y;
|
||||
|
||||
for(int i=0;i<particles.length;i++)
|
||||
for(int i=0;i<(particles.length - dead);i++)
|
||||
{
|
||||
Break particle = particles[i];
|
||||
TextureRef3D ref = particle.ref;
|
||||
|
|
@ -251,6 +302,10 @@ public class ParticleBreak extends EntityParticle implements IModel
|
|||
@Override
|
||||
public void bind()
|
||||
{
|
||||
if(isDead()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!generated)
|
||||
{
|
||||
int[] indicies = this.getIndicies();
|
||||
|
|
@ -280,6 +335,10 @@ public class ParticleBreak extends EntityParticle implements IModel
|
|||
@Override
|
||||
public void render()
|
||||
{
|
||||
if(isDead()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(Model.bound != this) {
|
||||
bind();
|
||||
}
|
||||
|
|
@ -293,11 +352,15 @@ public class ParticleBreak extends EntityParticle implements IModel
|
|||
}
|
||||
|
||||
@Override
|
||||
public void free() {
|
||||
GL33.glDeleteBuffers(ibo);
|
||||
GL33.glDeleteBuffers(vbo);
|
||||
GL33.glDeleteVertexArrays(vao);
|
||||
generated = false;
|
||||
public void free()
|
||||
{
|
||||
if(generated)
|
||||
{
|
||||
GL33.glDeleteBuffers(ibo);
|
||||
GL33.glDeleteBuffers(vbo);
|
||||
GL33.glDeleteVertexArrays(vao);
|
||||
generated = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setModel(Matrix4 model) {
|
||||
|
|
|
|||
|
|
@ -7,36 +7,32 @@ import gl_engine.vec.Vec2d;
|
|||
import gl_engine.vec.Vec3d;
|
||||
import projectzombie.entity.EntityParticle;
|
||||
import projectzombie.init.Models;
|
||||
import projectzombie.model.IModel;
|
||||
import projectzombie.model.Model;
|
||||
import projectzombie.util.math.random.RandomHelpers;
|
||||
import projectzombie.world.chunk.Chunk;
|
||||
import projectzombie.world.layer.Layer;
|
||||
|
||||
public class ParticleLava extends EntityParticle
|
||||
public class ParticleLava extends ParticleBreak
|
||||
{
|
||||
private static Random rand = new Random();
|
||||
|
||||
public ParticleLava(Vec3d pos, Vec3d velocity) {
|
||||
super(pos, velocity.add(MathHelpers.moveTowards3(0.05, new Vec2d(Math.toRadians(
|
||||
RandomHelpers.randrange(rand, 360)), Math.toRadians(RandomHelpers.randrange(rand, 0, 45))))));
|
||||
this(pos, velocity, 100);
|
||||
|
||||
this.still_ypos = -1;
|
||||
}
|
||||
|
||||
|
||||
public ParticleLava(Vec3d pos, Vec3d velocity, int count) {
|
||||
super(pos, velocity, Models.TILE_LAVA, count, 0.1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(Chunk chunk, Layer layer) {
|
||||
super.tick(chunk, layer);
|
||||
|
||||
// Is the height below 0; destroy this particle
|
||||
if(getPos().y < -1) {
|
||||
kill();
|
||||
}
|
||||
|
||||
if(DISABLED) {
|
||||
kill();
|
||||
}
|
||||
protected boolean isStill(Break particle) {
|
||||
return particle.pos.y <= -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Model getModel() {
|
||||
return Models.PARTICLE_LAVA;
|
||||
protected void onAllStill() {
|
||||
super.onAllStill();
|
||||
dead = particles.length - 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ public class ParticleSmoke extends EntityParticle
|
|||
RandomHelpers.randrange(rand, 1000)/1000.0 - 0.5 + pos.y)),
|
||||
velocity.add(new Vec3d(0, (rand.nextDouble() + 0.5) / 250, 0)));
|
||||
|
||||
hasGravity = false;
|
||||
disappear_speed = (rand.nextDouble() + 0.5) / 1000;
|
||||
model = Models.PARTICLE_SMOKE_RANDOM.getModel();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,106 @@
|
|||
package projectzombie.entity.particle;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import gl_engine.MathHelpers;
|
||||
import gl_engine.texture.TextureRef3D;
|
||||
import gl_engine.vec.Vec2d;
|
||||
import gl_engine.vec.Vec3d;
|
||||
import projectzombie.entity.Entity;
|
||||
import projectzombie.entity.EntityParticle;
|
||||
import projectzombie.init.Models;
|
||||
import projectzombie.model.IModel;
|
||||
import projectzombie.model.Model;
|
||||
import projectzombie.world.chunk.Chunk;
|
||||
import projectzombie.world.layer.Layer;
|
||||
|
||||
public class ParticleSmokeTrail extends ParticleBreak
|
||||
{
|
||||
private Entity parent;
|
||||
private double offset;
|
||||
|
||||
private boolean generating_particles = true;
|
||||
|
||||
public ParticleSmokeTrail(Entity parent, double offset, int count) {
|
||||
super(parent.getPos(), parent.getVelocity(), Models.PARTICLE_SMOKE_TRAIL, count);
|
||||
|
||||
time = count;
|
||||
do_gravity = false;
|
||||
|
||||
this.offset = offset;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec2d getParticleSize() {
|
||||
return new Vec2d(0.04, 0.04);
|
||||
}
|
||||
|
||||
public ParticleSmokeTrail(Entity parent, double offset) {
|
||||
this(parent, offset, 2000);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Break createParticle(
|
||||
IModel model, TextureRef3D ref, int tex_id, Vec3d pos, Vec3d velocity,
|
||||
float[] verticies, double velocity_up_multiplier, double model_height, int i)
|
||||
{
|
||||
Break particle = new Break();
|
||||
|
||||
particle.moving = false;
|
||||
particle.pos = pos.copy();
|
||||
particle.velocity = new Vec3d(0, 0, 0);
|
||||
particle.flags = ((int)verticies[tex_id * Model.SIZE + Model.SIZE - 1] & 0b0110) | 0b1000;
|
||||
particle.ref = ref;
|
||||
|
||||
return particle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(Chunk chunk, Layer layer) {
|
||||
super.tick(chunk, layer);
|
||||
|
||||
for(int i=0;i<particles.length;i++) {
|
||||
particles[i].time -= 1;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
Vec3d wind = layer.layergen.getWind(layer, getPos().xz());
|
||||
|
||||
if(generating_particles)
|
||||
{
|
||||
for(int i=0;i<particles.length&&count<10;i++)
|
||||
{
|
||||
if(!particles[i].moving || particles[i].time <= 0) {
|
||||
particles[i].pos = parent.getPos().add(new Vec3d(0, offset, 0));
|
||||
particles[i].velocity = parent.getVelocity()
|
||||
.multiply(0.5).add(
|
||||
MathHelpers.moveTowards3(
|
||||
MathHelpers.map(rand.nextDouble(), 0, 1, 0.004, 0.008), new Vec2d(
|
||||
rand.nextDouble() * MathHelpers.TWO_PI,
|
||||
rand.nextDouble() * MathHelpers.PI - MathHelpers.HALF_PI))).add(wind);
|
||||
particles[i].moving = true;
|
||||
particles[i].time = 200;
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
dead -= 1;
|
||||
if(dead >= particles.length) {
|
||||
dead = particles.length - 1;
|
||||
kill();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void stopParticles() {
|
||||
generating_particles = false;
|
||||
}
|
||||
|
||||
public boolean noMoreParticles() {
|
||||
return dead == particles.length - 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
package projectzombie.entity.particle;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import gl_engine.vec.Vec3d;
|
||||
import projectzombie.entity.EntityParticle;
|
||||
import projectzombie.init.Models;
|
||||
import projectzombie.model.Model;
|
||||
import projectzombie.world.chunk.Chunk;
|
||||
import projectzombie.world.layer.Layer;
|
||||
|
||||
public class ParticleSpark extends EntityParticle
|
||||
{
|
||||
private int time;
|
||||
|
||||
private static final Random rand = new Random();
|
||||
|
||||
public ParticleSpark(Vec3d pos) {
|
||||
super(pos, new Vec3d(
|
||||
rand.nextDouble() * 0.02 - 0.01,
|
||||
rand.nextDouble() * 0.02 - 0.01,
|
||||
rand.nextDouble() * 0.02));
|
||||
|
||||
time = 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(Chunk chunk, Layer layer) {
|
||||
super.tick(chunk, layer);
|
||||
|
||||
// Reduce the time
|
||||
time -= 1;
|
||||
|
||||
// Kill if at the end of life
|
||||
if(time <= 0 || DISABLED) {
|
||||
kill();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Model getModel() {
|
||||
return Models.PARTICLE_SMOKE_TRAIL;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -110,6 +110,7 @@ public class EntityPlayer extends Entity implements EntityAlive, EntityInventory
|
|||
inventory.addItem(new ItemStack(Items.SPAWN_DUMMY, 999, (short)0));
|
||||
inventory.addItem(new ItemStack(Items.SPAWN_ZOMBIE, 999, (short)0));
|
||||
inventory.addItem(new ItemStack(Items.LANTERN, 999, (short)0));
|
||||
inventory.addItem(new ItemStack(Items.FLARE, 999, (short)0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -135,6 +136,10 @@ public class EntityPlayer extends Entity implements EntityAlive, EntityInventory
|
|||
{
|
||||
chunk = layer.getChunk(getPos().xz());
|
||||
|
||||
temperature = 0.5;
|
||||
health = health_max;
|
||||
hydration = 1;
|
||||
|
||||
if(chunk != null && chunk.c_pos != null && (last_chunk == null || !chunk.c_pos.equal(last_chunk))) {
|
||||
last_chunk = chunk.c_pos;
|
||||
DisplayLighting.setDirty();
|
||||
|
|
@ -188,7 +193,7 @@ public class EntityPlayer extends Entity implements EntityAlive, EntityInventory
|
|||
chunk.getLightLevel(getPos().xz().toInt()) * 0.6) - temperature;
|
||||
|
||||
temperature += temp_diff / 1000;
|
||||
hydration -= MathHelpers.smoothStep(Math.abs(temperature - 0.4) + 0.1) / 1000;
|
||||
hydration -= MathHelpers.smoothStep(Math.abs(temperature - 0.4) + 0.1) / 20000;
|
||||
|
||||
if(temperature < 0.3) {
|
||||
health -= 0.3 - temperature;
|
||||
|
|
|
|||
|
|
@ -51,9 +51,7 @@ public class Models
|
|||
public static final Model ENTITY_GRAPPLING_HOOK = new ModelVertical(Resources.ATLAS.get("/entity/grappling_hook.png"));
|
||||
|
||||
public static final Model PARTICLE_BLOOD = new ModelVertical(Resources.ATLAS.get("/particle/blood.png"), new Vec2d(1, 1));
|
||||
public static final Model PARTICLE_LAVA = new ModelVertical(Resources.ATLAS.get("/particle/lava.png"), new Vec2d(0.1, 0.1));
|
||||
public static final Model PARTICLE_WATER = new ModelVertical(Resources.ATLAS.get("/particle/water.png"), new Vec2d(0.1, 0.1));
|
||||
public static final Model PARTICLE_SMOKE_TRAIL = new ModelVertical(Resources.ATLAS.get("/particle/smoke_trail.png"), new Vec2d(0.1, 0.1));
|
||||
public static final Model PARTICLE_SMOKE_TRAIL = new ModelVertical(Resources.ATLAS.get("/particle/smoke_trail.png"), new Vec2d(1, 1));
|
||||
public static final Model PARTICLE_BULLET = new ModelVertical(Resources.ATLAS.get("/particle/bullet.png"), new Vec2d(0.1, 0.1));
|
||||
|
||||
public static final ModelRandom PARTICLE_SMOKE_RANDOM = new ModelRandom(
|
||||
|
|
|
|||
|
|
@ -31,6 +31,11 @@ public class MainloopEventHandler implements IMainloopEvent, IMainloopTask
|
|||
@Override
|
||||
public void onLate() {
|
||||
mspf += 1;
|
||||
|
||||
// Dont let the fps go past 1 frame every 10 seconds
|
||||
if(mspf > 10000) {
|
||||
mspf = 10000;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -49,8 +49,10 @@ public class TileLava extends Tile
|
|||
public void tickRandomly(Layer layer, Chunk chunk, TileState state, Vec2i pos) {
|
||||
super.tickRandomly(layer, chunk, state, pos);
|
||||
|
||||
chunk.spawnEntity(new ParticleLava(new Vec3d(
|
||||
pos.x + rand.nextDouble(), 0, pos.y + rand.nextDouble()), new Vec3d(0, 0, 0)));
|
||||
if(rand.nextDouble() > 0.98) {
|
||||
chunk.spawnEntity(new ParticleLava(new Vec3d(
|
||||
pos.x + rand.nextDouble(), 0, pos.y + rand.nextDouble()), new Vec3d(0, 0, 0)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
package projectzombie.util.math.random;
|
||||
|
||||
public interface NoiseGenerator
|
||||
{
|
||||
public double eval(double x, double y);
|
||||
public double eval(double x, double y, double z);
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package projectzombie.util.math.random;
|
||||
|
||||
public class NoiseGeneratorSimplex implements NoiseGenerator
|
||||
{
|
||||
private OpenSimplexNoise simplex;
|
||||
|
||||
public NoiseGeneratorSimplex(long seed) {
|
||||
simplex = new OpenSimplexNoise(seed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double eval(double x, double y) {
|
||||
return simplex.eval(x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double eval(double x, double y, double z) {
|
||||
return simplex.eval(x, y, z);
|
||||
}
|
||||
}
|
||||
|
|
@ -18,6 +18,7 @@ import projectzombie.init.LayerGenerators;
|
|||
import projectzombie.util.math.TileState;
|
||||
import projectzombie.util.math.map.Map2D;
|
||||
import projectzombie.util.math.map.Map2DElement;
|
||||
import projectzombie.util.math.random.NoiseGenerator;
|
||||
import projectzombie.util.math.random.OpenSimplexNoise;
|
||||
import projectzombie.world.chunk.Chunk;
|
||||
import projectzombie.world.layer.layergen.LayerGen;
|
||||
|
|
@ -26,7 +27,7 @@ public class Layer implements IBdfClassManager
|
|||
{
|
||||
public Map2D<Chunk> chunks;
|
||||
private Map2D<Chunk> dirty_chunks;
|
||||
public OpenSimplexNoise[] noise_gens;
|
||||
public NoiseGenerator[] noise_gens;
|
||||
public LayerGen layergen;
|
||||
private Random rand;
|
||||
public long lseed;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import java.util.Random;
|
|||
|
||||
import gl_engine.vec.Vec2d;
|
||||
import gl_engine.vec.Vec2i;
|
||||
import gl_engine.vec.Vec3d;
|
||||
import projectzombie.util.math.ColorRange;
|
||||
import projectzombie.util.math.TileState;
|
||||
import projectzombie.util.math.map.IMap2D;
|
||||
|
|
@ -15,6 +16,10 @@ public abstract class LayerGen implements IMap2D<Chunk>
|
|||
public int id;
|
||||
public boolean destroyOnLeave = false;
|
||||
|
||||
public Vec3d getWind(Layer layer, Vec2d pos) {
|
||||
return new Vec3d(0, 0, 0);
|
||||
}
|
||||
|
||||
public abstract void generateChunk(Chunk chunk, Layer layer, Random rand, Vec2i pos);
|
||||
public abstract double getTemperatureStatic(Layer layer, Vec2d pos);
|
||||
public abstract double getTemperatureDynamic(Layer layer, Vec2d pos);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ import projectzombie.entity.EntityZombie;
|
|||
import projectzombie.init.Tiles;
|
||||
import projectzombie.util.math.ColorRange;
|
||||
import projectzombie.util.math.TileState;
|
||||
import projectzombie.util.math.random.NoiseGenerator;
|
||||
import projectzombie.util.math.random.NoiseGeneratorSimplex;
|
||||
import projectzombie.util.math.random.OpenSimplexNoise;
|
||||
import projectzombie.util.math.random.RandomHelpers;
|
||||
import projectzombie.world.chunk.Chunk;
|
||||
|
|
@ -24,7 +26,7 @@ public class LayerGenCaves extends LayerGen
|
|||
public double getTemperatureStatic(Layer layer, Vec2d pos)
|
||||
{
|
||||
// Get the noise generator
|
||||
OpenSimplexNoise terrain_noise = layer.noise_gens[0];
|
||||
NoiseGenerator terrain_noise = layer.noise_gens[0];
|
||||
return MathHelpers.map(terrain_noise.eval(pos.x/64.0, pos.y/64.0), -1, 1, 0, 0.6);
|
||||
}
|
||||
|
||||
|
|
@ -37,7 +39,7 @@ public class LayerGenCaves extends LayerGen
|
|||
public double getHumidity(Layer layer, Vec2d pos)
|
||||
{
|
||||
// Get the noise generator
|
||||
OpenSimplexNoise terrain_noise = layer.noise_gens[1];
|
||||
NoiseGenerator terrain_noise = layer.noise_gens[1];
|
||||
return MathHelpers.map(terrain_noise.eval(pos.x/64.0, pos.y/64.0), -1, 1, 0.3, 0.8);
|
||||
}
|
||||
|
||||
|
|
@ -47,9 +49,9 @@ public class LayerGenCaves extends LayerGen
|
|||
|
||||
Random rand = new Random(layer.seed);
|
||||
|
||||
layer.noise_gens = new OpenSimplexNoise[] {
|
||||
new OpenSimplexNoise(rand.nextLong()),
|
||||
new OpenSimplexNoise(rand.nextLong())
|
||||
layer.noise_gens = new NoiseGenerator[] {
|
||||
new NoiseGeneratorSimplex(rand.nextLong()),
|
||||
new NoiseGeneratorSimplex(rand.nextLong())
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ import projectzombie.init.Tiles;
|
|||
import projectzombie.time.GameTimer;
|
||||
import projectzombie.util.math.ColorRange;
|
||||
import projectzombie.util.math.TileState;
|
||||
import projectzombie.util.math.random.NoiseGenerator;
|
||||
import projectzombie.util.math.random.NoiseGeneratorSimplex;
|
||||
import projectzombie.util.math.random.OpenSimplexNoise;
|
||||
import projectzombie.util.math.random.RandomHelpers;
|
||||
import projectzombie.world.chunk.Chunk;
|
||||
|
|
@ -20,12 +22,19 @@ import projectzombie.world.layer.Layer;
|
|||
|
||||
public class LayerGenEarth extends LayerGen
|
||||
{
|
||||
@Override
|
||||
public Vec3d getWind(Layer layer, Vec2d pos) {
|
||||
double t = GameTimer.getTime() / 1000.0;
|
||||
return new Vec3d(
|
||||
layer.noise_gens[2].eval(pos.x / 100, pos.y / 100, t) * 0.02, 0,
|
||||
layer.noise_gens[3].eval(pos.x / 100, pos.y / 100, t) * 0.02);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTemperatureStatic(Layer layer, Vec2d pos)
|
||||
{
|
||||
// Get the noise generator
|
||||
OpenSimplexNoise terrain_noise = layer.noise_gens[0];
|
||||
NoiseGenerator terrain_noise = layer.noise_gens[0];
|
||||
return MathHelpers.map(terrain_noise.eval(pos.x/64.0, pos.y/64.0), -1, 1, 0, 0.8);
|
||||
}
|
||||
|
||||
|
|
@ -34,7 +43,7 @@ public class LayerGenEarth extends LayerGen
|
|||
{
|
||||
// Get the noise generator
|
||||
double light = (MathHelpers.sin(GameTimer.getTime() / 7200.0 - MathHelpers.PI / 4) + 1) * 0.2;
|
||||
OpenSimplexNoise terrain_noise = layer.noise_gens[0];
|
||||
NoiseGenerator terrain_noise = layer.noise_gens[0];
|
||||
return MathHelpers.map(terrain_noise.eval(pos.x/64.0, pos.y/64.0), -1, 1, 0, 0.6 + light);
|
||||
}
|
||||
|
||||
|
|
@ -42,7 +51,7 @@ public class LayerGenEarth extends LayerGen
|
|||
public double getHumidity(Layer layer, Vec2d pos)
|
||||
{
|
||||
// Get the noise generator
|
||||
OpenSimplexNoise terrain_noise = layer.noise_gens[1];
|
||||
NoiseGenerator terrain_noise = layer.noise_gens[1];
|
||||
return MathHelpers.map(terrain_noise.eval(pos.x/64.0, pos.y/64.0), -1, 1, 0, 1);
|
||||
}
|
||||
|
||||
|
|
@ -52,9 +61,13 @@ public class LayerGenEarth extends LayerGen
|
|||
|
||||
Random rand = new Random(layer.seed);
|
||||
|
||||
layer.noise_gens = new OpenSimplexNoise[] {
|
||||
new OpenSimplexNoise(rand.nextLong()),
|
||||
new OpenSimplexNoise(rand.nextLong())
|
||||
layer.noise_gens = new NoiseGenerator[]
|
||||
{
|
||||
new NoiseGeneratorSimplex(rand.nextLong()),
|
||||
new NoiseGeneratorSimplex(rand.nextLong()),
|
||||
|
||||
new NoiseGeneratorSimplex(rand.nextLong()),
|
||||
new NoiseGeneratorSimplex(rand.nextLong()),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -69,7 +82,7 @@ public class LayerGenEarth extends LayerGen
|
|||
RandomHelpers.randrange(rand, Chunk.CHUNK_SIZE.my));
|
||||
|
||||
// Get the noise generator
|
||||
OpenSimplexNoise noise_terrain = layer.noise_gens[0];
|
||||
NoiseGenerator noise_terrain = layer.noise_gens[0];
|
||||
|
||||
// Loop over the layer dimensions and create land
|
||||
for(int x=0;x<Chunk.CHUNK_SIZE.mx;x++) {
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ void main()
|
|||
FragColor = texture(atlas, pTexture) * (mod(int(pFlags / 4), 2) == 1 ? color_grass : vec4(1,1,1,1)) *
|
||||
color * vec4(biggest(light_day, light_src), 1);
|
||||
|
||||
float saturation = contrast * 2 + 1;
|
||||
float saturation = contrast * 1.6 + 1;
|
||||
|
||||
FragColor.x = min(1, FragColor.x * saturation + contrast);
|
||||
FragColor.y = min(1, FragColor.y * saturation + contrast);
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ void main()
|
|||
{
|
||||
int type = int(aFlags.z);
|
||||
|
||||
vec4 pos = vec4(aPos, 1) * (mod(type >> 4, 2) == 1 ? billboard : (mod(type, 2) == 1 ? rotated : mat4(1))) *
|
||||
vec4 pos = vec4(aPos, 1) * (mod(type >> 3, 2) == 1 ? billboard : (mod(type, 2) == 1 ? rotated : mat4(1))) *
|
||||
translate(aChunkOffset) * model;
|
||||
|
||||
gl_Position = pos * projection;
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 557 B After Width: | Height: | Size: 2.5 KiB |
Loading…
Reference in New Issue