42 lines
1.1 KiB
Java
42 lines
1.1 KiB
Java
|
|
public class Player extends GameItem
|
|
{
|
|
public static final double DEFAULT_RADIUS = 0.06;
|
|
public static final double COLLIDE_DAMAGE = 0.002;
|
|
public static final double SHOT_DELAY = 4.0;
|
|
|
|
public String name;
|
|
public double health;
|
|
public double r;
|
|
public double dr;
|
|
public long lastShotTime;
|
|
|
|
public Player(String name)
|
|
{
|
|
this.name = name;
|
|
this.radius = DEFAULT_RADIUS;
|
|
this.health = 1.0;
|
|
this.r = Math.random() * Math.PI * 2;
|
|
this.dr = 0;
|
|
this.dx = 0;
|
|
this.dy = 0;
|
|
}
|
|
|
|
public boolean equals(Player other)
|
|
{
|
|
return this.name.equals(other.name) &&
|
|
this.radius == other.radius &&
|
|
this.health == other.health &&
|
|
this.r == other.r &&
|
|
this.dr == other.dr &&
|
|
this.dx == other.dx &&
|
|
this.dy == other.dy;
|
|
}
|
|
|
|
public String toString()
|
|
{
|
|
return String.format("%s:%.3f:%.3f:%.3f:%.3f:%.3f:%.3f:%.3f:%.3f",
|
|
name, radius, health, x, y, r, dr, dx, dy);
|
|
}
|
|
}
|