From 39e4f42dc6efee35ddfca684674b849febbd87fb Mon Sep 17 00:00:00 2001 From: 16nlyons Date: Thu, 2 Jun 2016 09:20:15 -0400 Subject: [PATCH] created enemy tank class with constructor and move method --- src/tanks/Tanks.java | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/src/tanks/Tanks.java b/src/tanks/Tanks.java index e4cf7e7..a860d47 100644 --- a/src/tanks/Tanks.java +++ b/src/tanks/Tanks.java @@ -417,9 +417,47 @@ public class Tanks private class Tank extends Enemy { - @Override - public void move() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + Bullet b; + Turret t; + Timer tim; + public Tank() + { + super(); + speed=3; + ActionListener al = new ActionListener() + { + + @Override + public void actionPerformed(ActionEvent e) + { + b = new Bullet(t); + b.enemyBullet=true; + bullets.add(b); + } + + }; + tim = new Timer(3500,al); + tim.start(); + } + public void move() + { + if(this.distToPlayer(p)>150) + { + direction = angleToPlayer(p); + super.move(-1); + if(this.checkCollision(p)) + { + enemy.remove(this); + p.takeDamage(); + if(!p.isAlive) + { + wave.setGameMode(2); + } + } + } + t.x=this.x+25; + t.y=this.y+25; + t.direction=this.angleToPlayer(p); } }