73 lines
1.8 KiB
Java
Executable File
73 lines
1.8 KiB
Java
Executable File
package projectzombie.entity.particle;
|
|
|
|
import java.util.Random;
|
|
|
|
import projectzombie.display.Camera;
|
|
import projectzombie.entity.EntityParticle;
|
|
import projectzombie.init.Models;
|
|
import projectzombie.model.Model;
|
|
import projectzombie.settings.SettingQuality;
|
|
import projectzombie.util.gl.GlHelpers;
|
|
import gl_engine.MathHelpers;
|
|
import projectzombie.util.math.random.RandomHelpers;
|
|
import gl_engine.vec.Vec2d;
|
|
import gl_engine.vec.Vec2i;
|
|
import gl_engine.vec.Vec3d;
|
|
import projectzombie.world.chunk.Chunk;
|
|
import projectzombie.world.layer.Layer;
|
|
|
|
public class ParticleBlood extends EntityParticle
|
|
{
|
|
private double r_color;
|
|
private double time = 1000;
|
|
private double height = 0;
|
|
private Vec3d velocity;
|
|
|
|
public ParticleBlood(Random rand, Vec2d pos, double angle) {
|
|
super(pos);
|
|
|
|
angle += RandomHelpers.randrange(rand, -100, 100);
|
|
double angle_height = RandomHelpers.randrange(rand, 9000, 18000) / 100;
|
|
this.height = rand.nextDouble();
|
|
r_color = RandomHelpers.randrange(rand, 200, 800) / 1000.0;
|
|
velocity = MathHelpers.moveTowards3(0.1,
|
|
new Vec2d(Math.toRadians(angle), Math.toRadians(angle_height)));
|
|
|
|
time = RandomHelpers.randrange(rand, 800, 1200);
|
|
}
|
|
|
|
@Override
|
|
public void tick(Chunk chunk, Layer layer)
|
|
{
|
|
// Call super
|
|
super.tick(chunk, layer);
|
|
|
|
// Move in the velocity and remove some of it
|
|
pos.x += velocity.x;
|
|
pos.y += velocity.y;
|
|
height += velocity.z;
|
|
velocity.x /= 1.05;
|
|
velocity.y /= 1.05;
|
|
velocity.z -= MathHelpers.FallSpeed;
|
|
if(height < 0) {
|
|
height = 0;
|
|
velocity.z = 0;
|
|
}
|
|
|
|
// Remove some time
|
|
time -= 1;
|
|
|
|
// Should this particle too old; destroy it
|
|
if(time < 0) chunk.killEntity(this);
|
|
|
|
if(MODE == SettingQuality.OFF) {
|
|
kill();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public Model getModel() {
|
|
return Models.PARTICLE_BLOOD;
|
|
}
|
|
}
|