84 lines
2.1 KiB
Java
Executable File
84 lines
2.1 KiB
Java
Executable File
package projectzombie.entity.particle;
|
|
|
|
import java.util.Random;
|
|
|
|
import projectzombie.display.Camera;
|
|
import projectzombie.entity.EntityParticle;
|
|
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, rand.nextDouble() / 5, 0);
|
|
|
|
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 void render(Vec2d pos, Camera camera)
|
|
{
|
|
// Get the light level
|
|
Vec3d light = chunk.getRGBLightLevel(new Vec2i(
|
|
MathHelpers.floor(pos.x), MathHelpers.floor(pos.y)));
|
|
|
|
// Set some settings
|
|
GlHelpers.pushMatrix();
|
|
GlHelpers.color3(r_color * light.x, 0, 0);
|
|
GlHelpers.translate3(0, 0, height);
|
|
|
|
// Call super
|
|
super.render(pos, camera);
|
|
GlHelpers.color3(1, 1, 1);
|
|
GlHelpers.popMatrix();
|
|
}
|
|
}
|