Select Git revision
David Lin authored
Tank.java 1.01 KiB
package lists;
import bagel.Input;
import bagel.util.Point;
import java.util.ArrayList;
import java.util.List;
public class Tank extends Sprite{
protected double radius,cooldown;
protected int damage;
protected Point tankPoint;
protected Slicer target;
public Tank(Point point, String imageSrc) {
super(point, imageSrc);
this.radius = 100;
this.damage = 1;
this.cooldown = 1000;
this.tankPoint = point;
this.target = null;
}
public void attack(Slicer slicer){
if (slicer.health > 0){
slicer.health-=damage;
}
}
@Override
public void update(Input input) {
if(target != null){
// Obtain where we currently are, and where we want to be
Point currentPoint = getCenter();
Point targetPoint = target.getCenter();
setAngle(Math.atan2(targetPoint.y - currentPoint.y, targetPoint.x - currentPoint.x)+Math.PI/2);
}
super.update(input);
}
}