Skip to content
Snippets Groups Projects
Select Git revision
  • 1091c1c990d6a4cc64ee1ce3deff93839e45bb42
  • master default protected
2 results

Tank.java

Blame
  • 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);
        }
    
    
    
    }