ProjectZombie/src/shootergame/entity/EntityZombie.java

79 lines
1.4 KiB
Java

package shootergame.entity;
import java.util.Random;
import shootergame.Main;
import shootergame.init.Textures;
import shootergame.util.math.random.OpenSimplexNoise;
import shootergame.world.chunk.Chunk;
import shootergame.world.layer.Layer;
public class EntityZombie extends EntityVertical implements EntityAlive
{
private Random rand;
private OpenSimplexNoise noise;
private double time;
private double health_max = 100;
private double health = health_max;
public EntityZombie() {
super(Textures.ENTITY_ZOMBIE, 1);
rand = new Random();
noise = new OpenSimplexNoise(rand.nextLong());
time = 0;
// Set some settings
hitbox = 0.5;
isSolid = true;
}
@Override
public void tick(Chunk chunk, Layer layer) {
super.tick(chunk, layer);
double angle = Math.atan2(pos.x - Main.player.pos.x, pos.y - Main.player.pos.y);
this.angle = Math.toDegrees(angle) + 180;
this.angle += noise.eval(time, 0)*60;
time += 0.001;
this.moveForward(0.05);
}
@Override
public void addHealth(double amount) {
health += amount;
}
@Override
public void removeHealth(double amount) {
health -= amount;
}
@Override
public double getHealth() {
return health;
}
@Override
public void resetHealth() {
health = health_max;
}
@Override
public void clearHealth() {
health = 0;
}
@Override
public double maxHealth() {
return health_max;
}
@Override
public void setHealth(double health) {
this.health = health;
}
}