diff --git a/src/Airplane.java b/src/Airplane.java index f1c6785252e1b93cfef55946800b184b1a16fb5d..d9481113f098192e04849511d818797f06d678a3 100644 --- a/src/Airplane.java +++ b/src/Airplane.java @@ -6,6 +6,9 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; +/** + * An airplane. + */ public class Airplane extends Sprite{ private static final String EXPLOSIVE_FILE = "res/images/explosive.png"; private static final int HEIGHT = 768; @@ -14,22 +17,20 @@ public class Airplane extends Sprite{ private static final double TIME_MAX = 2; private final List<Explosive> explosives; - - private double speed; + private double speed, frameCount, nothingTime; private int damage; private boolean finished, isVertical; - private double frameCount; private Random r = new Random(); - private double nothingTime; private Point explode; - - - - - + /** + * Creates a new Airplane + * + * @param point The point where the image is to be drawn + * @param isVertical Whether Airplane will go horizontally or vertically + */ public Airplane(Point point, boolean isVertical, String imageSrc){ super(point,imageSrc); - this.speed = 1.5; + this.speed = 3; this.damage = 500; this.finished = false; this.isVertical = isVertical; @@ -46,6 +47,10 @@ public class Airplane extends Sprite{ return this.damage; } + /** + * Updates the current state of the airplane. The airplane moves towards its next target point + * at its specified movement rate. + */ @Override public void update(Input input) { explode = null; @@ -53,23 +58,22 @@ public class Airplane extends Sprite{ if (finished) { return; } + // Let plane move either horizontally or vertically Point currentPoint = getCenter(); Point targetPoint = new Point(currentPoint.x + 3,currentPoint.y); setAngle(Math.PI/2); if(isVertical){ targetPoint = new Point(currentPoint.x,currentPoint.y + 3); - setAngle(Math.PI); - } Vector2 target = targetPoint.asVector(); Vector2 current = currentPoint.asVector(); Vector2 distance = target.sub(current); - double magnitude = distance.length(); if (frameCount*1000 / ShadowDefend.FPS >= nothingTime &&(currentPoint.x < WIDTH && currentPoint.y < HEIGHT)) { + // Add explosives at current point every 1-2 seconds explosives.add(new Explosive(currentPoint,EXPLOSIVE_FILE)); nothingTime = Math.round((TIME_MIN + (TIME_MAX - TIME_MIN) * r.nextDouble())*1000); frameCount = 0; @@ -77,20 +81,19 @@ public class Airplane extends Sprite{ // Check if we have reached the end if ((currentPoint.x >= WIDTH || currentPoint.y >= HEIGHT) && explosives.isEmpty()) { - //System.out.println("out"); finished = true; return; } + for (int i = explosives.size() - 1; i >= 0; i--) { if(!explosives.isEmpty()){ - //System.out.println(explosives); + Explosive v = explosives.get(i); v.update(input); if (v.isFinished()) { - + // Set explosion to occur explode = v.getPoint(); - explosives.remove(i); } } diff --git a/src/ApexSlicer.java b/src/ApexSlicer.java index 6172da7027406d8d6d9ce150140ec9d4aa78689e..c534756cf8464a4cf6d5b30708ae5d2bcea4cad9 100644 --- a/src/ApexSlicer.java +++ b/src/ApexSlicer.java @@ -4,7 +4,7 @@ import bagel.util.Point; import java.util.List; /** - * A super slicer. + * An apex slicer. */ public class ApexSlicer extends Slicer { @@ -18,7 +18,7 @@ public class ApexSlicer extends Slicer { public ApexSlicer(List<Point> polyline,int targetPointIndex, Point point,String imageSrc) { super(polyline, targetPointIndex, point, imageSrc); - this.speed = 0.375; + this.speed = 0.75; this.health = 25; this.reward = 150; this.penalty = 16; diff --git a/src/Explosive.java b/src/Explosive.java index b70e162f52a4ccd839af5c220763cf93b63c4eed..926ea8e3a48fb23a48510fe6348a0bcd99f756ba 100644 --- a/src/Explosive.java +++ b/src/Explosive.java @@ -1,17 +1,19 @@ import bagel.Input; import bagel.util.Point; - +/** + * An explosive. + */ public class Explosive extends Sprite{ private static final double COOLDOWN = 2000; private double radius,frameCount; private boolean finished; - private Point point; - - - - + /** + * Creates a new Explosive + * + * @param point The point where the image is to be drawn + */ public Explosive(Point point, String imageSrc){ super(point,imageSrc); this.radius = 200; @@ -25,6 +27,9 @@ public class Explosive extends Sprite{ public Point getPoint(){ return this.point; } + /** + * Updates the current state of the explosive. The explosive waits the allotted time and explodes. + */ @Override public void update(Input input) { frameCount += ShadowDefend.getTimescale(); @@ -32,9 +37,8 @@ public class Explosive extends Sprite{ return; } if (frameCount*1000 / ShadowDefend.FPS >= COOLDOWN) { - + // Explodes after waiting COOLDOWN time finished = true; - } super.update(input); } diff --git a/src/MegaSlicer.java b/src/MegaSlicer.java index f992cdcf70de391ca5c2bb035a5c1ddc94196e21..fc31924af25d0f84998a13a7419ee1324b252b6e 100644 --- a/src/MegaSlicer.java +++ b/src/MegaSlicer.java @@ -4,7 +4,7 @@ import bagel.util.Point; import java.util.List; /** - * A super slicer. + * A mega slicer. */ public class MegaSlicer extends Slicer { @@ -18,7 +18,7 @@ public class MegaSlicer extends Slicer { public MegaSlicer(List<Point> polyline, int targetPointIndex, Point point,String imageSrc) { super(polyline, targetPointIndex, point,imageSrc); - this.speed = 0.75; + this.speed = 1.5; this.health = 2; this.reward = 10; this.penalty = 4; diff --git a/src/Projectile.java b/src/Projectile.java index 4a38e94654cd5af1adbe4c7777c1e357f13e3725..ee7282dde0a2590be3679e906d7daffdaf16020c 100644 --- a/src/Projectile.java +++ b/src/Projectile.java @@ -2,18 +2,27 @@ import bagel.Input; import bagel.util.Point; import bagel.util.Vector2; - +/** + * A projectile. + */ public class Projectile extends Sprite { - protected boolean finished; - protected double speed; - protected int damage,slicerIndex; - protected Slicer target; - + private boolean finished; + private double speed; + private int damage,slicerIndex; + private Slicer target; + /** + * Creates a new Projectile + * + * @param point The point where the image is to be drawn + * @param damage Projectile's damage + * @param target Projectile's target slicer + * @param slicerIndex Index of target slicer in slicers + */ public Projectile(Point point, Slicer target,int damage,int slicerIndex, String imageSrc){ super(point, imageSrc); this.target = target; - this.speed = 5; + this.speed = 10; this.damage = damage; this.slicerIndex = slicerIndex; } @@ -24,7 +33,10 @@ public class Projectile extends Sprite { public int getDamage() { return this.damage; } - + /** + * Updates the current state of the projectile. The projectile moves towards its next target point + * at its specified movement rate. + */ @Override public void update(Input input) { if (finished) { @@ -38,8 +50,6 @@ public class Projectile extends Sprite { Vector2 targetVector = targetPoint.asVector(); Vector2 currentVector = currentPoint.asVector(); Vector2 distance = targetVector.sub(currentVector); - // Distance we are (in pixels) away from our target point - double magnitude = distance.length(); // Check if we have reached the end if (getRect().intersects(target.getRect())) { diff --git a/src/RegularSlicer.java b/src/RegularSlicer.java index ca63d6b7de686a7c49eef106e969b0b4ee0f0ee2..51c1931f6ed1fffa409dcc85d6563c371205bb84 100644 --- a/src/RegularSlicer.java +++ b/src/RegularSlicer.java @@ -16,12 +16,11 @@ public class RegularSlicer extends Slicer { public RegularSlicer(List<Point> polyline, int targetPointIndex, Point point, String imageSrc) { super(polyline, targetPointIndex, point, imageSrc); - this.speed = 1; + this.speed = 2; this.health = 1; this.reward = 2; this.penalty = 1; this.spawnOnDeath = 0; - } /** diff --git a/src/ShadowDefend.java b/src/ShadowDefend.java index 7f9742fb709f8428f0b57083e3f715b0d154001d..afeddf1b25682a2d2692d3af36cd8ef587faf8d7 100644 --- a/src/ShadowDefend.java +++ b/src/ShadowDefend.java @@ -20,16 +20,18 @@ import java.util.Scanner; * Used Rohyl's template from Project 1 */ public class ShadowDefend extends AbstractGame { + // Resource files and constants private static final String RSLICER = "res/images/slicer.png"; private static final String SSLICER = "res/images/superslicer.png"; private static final String MSLICER = "res/images/megaslicer.png"; private static final String ASLICER = "res/images/apexslicer.png"; + private static final int LIVES = 25; + private static final int GOLD = 500; private static final int HEIGHT = 768; private static final int WIDTH = 1024; private static final int HALF_WIDTH = WIDTH/2; private static final int QUAR_WIDTH = WIDTH/4; private static final int EXP_RADIUS = 200; - private static final String SHOP_FILE = "res/images/buypanel.png"; private static final String STATUS_FILE = "res/images/statuspanel.png"; private static final String TANK_FILE = "res/images/tank.png"; @@ -39,59 +41,91 @@ public class ShadowDefend extends AbstractGame { private static final String PLANE_FILE = "res/images/airsupport.png"; private static final String FONT_FILE = "res/fonts/DejaVuSans-Bold.ttf"; private static final String INFO = "Key binds:\n\nS - Start Wave\nL - Increase Timescale\nK - Decrease Timescale"; + private static final String WAVES_FILE = "res/levels/waves.txt"; + // For coloured text private DrawOptions colour = new DrawOptions(); + // Change to suit system specifications. This could be // dynamically determined but that is out of scope. public static final double FPS = 60; - // The spawn delay (in seconds) to spawn slicers + // Initial timescale private static final int INTIAL_TIMESCALE = 1; // Timescale is made static because it is a universal property of the game and the specification // says everything in the game is affected by this private static int timescale = INTIAL_TIMESCALE; + // Images for the buy and status panel private final Image shop, statusPanel, tankIcon, stankIcon, planeIcon; - private final List<Slicer> slicers; - private final List<Projectile> projectiles; + // Font for the buy and status panel + private Font goldDisplay, keyInstruction, costText, statusText; + // Image when placing tower + private Image placingIcon; + private String placedImage; + // Entity lists + private final List<Slicer> slicers; + private final List<Projectile> projectiles; private final List<Tank> tanks; - private final List<Airplane> planes; + // Represents window private final Rectangle window; + + // Map file which changes according to level private String map_file = "res/levels/1.tmx"; + + // The game map private TiledMap map; - private List<String> event; + + // The line slicers follow private List<Point> polyline; + // Event data from waves.txt + private List<String> event; private List<List<String>> events; - private Font goldDisplay, keyInstruction, costText, statusText; - private Image placingIcon; - private double frameCount; - private double projCount; - private int spawnedSlicers; - private int nothingTime; private int spawnDelay; private int spawnCount; private int eventType; + private String enemyType; + + // Frame counts + private double frameCount; + private double projCount; + + // Time for Delay event + private int nothingTime; + + // Event variables + private boolean waveStarted; private int level; + private int spawnedSlicers; private int waveCounter; private int eventCounter; private int prevWaveState; - private int slicerIndex; private boolean eventWait; - private String enemyType; - private String placedImage; + private boolean eventStarted = true; + + // For projectile to assign damage + private int slicerIndex; + + // Whether a tank is placed or not private boolean tankBlocked; + + // Has new map been set private boolean mapSet; - private boolean waveStarted; - private boolean eventStarted = true; + + // Plane flight direction private boolean isVertical = false; + + // Whether a tank has a target private boolean hasTarget = false; + + // Ongoing key game variables private static int gold, lives, waveNumber, waveState; @@ -101,9 +135,9 @@ public class ShadowDefend extends AbstractGame { public ShadowDefend() { super(WIDTH, HEIGHT, "ShadowDefend"); - - gold = 50000; - lives = 25; + // Initialise variables + gold = GOLD; + lives = LIVES; waveNumber = 1; waveState = 0; this.window = new Rectangle(0,0,WIDTH,HEIGHT); @@ -120,11 +154,8 @@ public class ShadowDefend extends AbstractGame { this.polyline = map.getAllPolylines().get(0); this.slicers = new ArrayList<>(); this.projectiles = new ArrayList<>(); - this.tanks = new ArrayList<>(); - this.planes = new ArrayList<>(); - this.events = new ArrayList<>(); this.event = new ArrayList<>(); this.level = 1; @@ -148,12 +179,6 @@ public class ShadowDefend extends AbstractGame { } catch (FileNotFoundException e) { e.printStackTrace(); } - - - - // Temporary fix for the weird slicer map glitch (might have to do with caching textures) - // This fix is entirely optional - //new Slicer(polyline); } /** @@ -193,6 +218,8 @@ public class ShadowDefend extends AbstractGame { private void resetLevel(){ map = new TiledMap(map_file); mapSet = false; + lives = LIVES; + gold = GOLD; level += 1; slicers.clear(); tanks.clear(); @@ -200,6 +227,7 @@ public class ShadowDefend extends AbstractGame { projectiles.clear(); polyline = map.getAllPolylines().get(0); eventCounter = 0; + waveNumber = 1; waveCounter = 1; waveState = 0; waveStarted = false; @@ -435,7 +463,13 @@ public class ShadowDefend extends AbstractGame { } } + // User has not placed tower by right clicking again + if(input.wasPressed(MouseButtons.RIGHT) && placingIcon != null){ + // Reset wave state and placing image to previous wave state and null + waveState = prevWaveState; + placingIcon = null; + } // User has placed tower by left clicking again, filter blocked areas if(input.wasPressed(MouseButtons.LEFT) && placingIcon != null && !map.hasProperty((int)Math.round(input.getMouseX()),(int)Math.round(input.getMouseY()),"blocked") @@ -586,7 +620,7 @@ public class ShadowDefend extends AbstractGame { } else if (eventType == 0) { eventWait = true; // Wait out specified delay - if (frameCount*1000 / FPS >= nothingTime) { + if (frameCount*1000 / FPS >= nothingTime){ // Reset wait, started and frame count for next event eventWait = false; eventStarted = false; @@ -594,147 +628,149 @@ public class ShadowDefend extends AbstractGame { frameCount = 0; } } - } - } - - - + // Update all sprites, and remove them if they've finished + + // Update all tanks + for (int j = tanks.size() - 1; j >= 0; j--) { + if (!tanks.isEmpty()) { + // Select a tank object + Tank v = tanks.get(j); + // Set tank target to null + v.setTarget(null); + // Find closest slicer + for (int i = 0; i <= slicers.size() - 1; i++) { + if(!slicers.isEmpty()){ + Slicer s = slicers.get(i); + // Checks if slicer within range and has health + if (v.getCenter().distanceTo(s.getCenter()) < v.getRadius() && s.getHealth() > 0 && !hasTarget) { + // Successfully found closest slicer and within tank range + v.setTarget(s); + slicerIndex = i; + hasTarget = true; + } + } + } + // Checks if tank has target + if(hasTarget){ + // Shoot projectile at target once in every cooldown period + if (projCount*1000 / FPS >= v.getCooldown()) { + if(v.getDamage() == 1){ + // Tank projectile + projectiles.add(new Projectile(v.getTankPoint(),v.getTarget(),v.getDamage(),slicerIndex,TANK_PROJ_FILE)); + } else { + // Super Tank projectile + projectiles.add(new Projectile(v.getTankPoint(),v.getTarget(),v.getDamage(),slicerIndex,STANK_PROJ_FILE)); + } + // Reset projectile frame count + projCount = 0; + } + } + v.update(input); + hasTarget = false; - // Update all sprites, and remove them if they've finished - // Update all tanks - for (int j = tanks.size() - 1; j >= 0; j--) { - if (!tanks.isEmpty()) { - // Select a tank object - Tank v = tanks.get(j); - // Set tank target to null - v.setTarget(null); - // Find closest slicer - for (int i = 0; i <= slicers.size() - 1; i++) { - if(!slicers.isEmpty()){ - Slicer s = slicers.get(i); - // Checks if slicer within range and has health - if (v.getCenter().distanceTo(s.getCenter()) < v.getRadius() && s.getHealth() > 0 && !hasTarget) { - // Successfully found closest slicer and within tank range - v.setTarget(s); - slicerIndex = i; - hasTarget = true; - } - } } - // Checks if tank has target - if(hasTarget){ - // Shoot projectile at target once in every cooldown period - if (projCount*1000 / FPS >= v.getCooldown()) { - if(v.getDamage() == 1){ - // Tank projectile - projectiles.add(new Projectile(v.getTankPoint(),v.getTarget(),v.getDamage(),slicerIndex,TANK_PROJ_FILE)); - } else { - // Super Tank projectile - projectiles.add(new Projectile(v.getTankPoint(),v.getTarget(),v.getDamage(),slicerIndex,STANK_PROJ_FILE)); + } + // Update all projectiles + for (int i = projectiles.size() - 1; i >= 0; i--) { + if(!projectiles.isEmpty()){ + Projectile t = projectiles.get(i); + + t.update(input); + // Projectile has hit a slicer + if (t.isFinished()) { + if(t.getSlicerIndex()<slicers.size()){ + // Remove appropriate health from slicer + slicers.get(t.getSlicerIndex()).setHealth(slicers.get(t.getSlicerIndex()).getHealth()-t.getDamage()); } - // Reset projectile frame count - projCount = 0; + + // Remove projectile + projectiles.remove(i); } } - v.update(input); - hasTarget = false; - - } - } - // Update all projectiles - for (int i = projectiles.size() - 1; i >= 0; i--) { - if(!projectiles.isEmpty()){ - Projectile t = projectiles.get(i); - - t.update(input); - // Projectile has hit a slicer - if (t.isFinished()) { - if(t.getSlicerIndex()<slicers.size()){ - // Remove appropriate health from slicer - slicers.get(t.getSlicerIndex()).setHealth(slicers.get(t.getSlicerIndex()).getHealth()-t.getDamage()); + // Update all planes + for (int i = planes.size() - 1; i >= 0; i--) { + if(!planes.isEmpty()){ + Airplane v = planes.get(i); + v.update(input); + // Check if any of the plane's explosives are going to explode + if(v.getExplode()!=null){ + // One of the planes explosives is ready to explode + // Create a range for explosion to occur + Rectangle r = new Rectangle(v.getExplode().x-EXP_RADIUS, + v.getExplode().y-EXP_RADIUS, + EXP_RADIUS*2, + EXP_RADIUS*2); + // Remove appropriate health from all slicers in range + for (int j = slicers.size() - 1; j >= 0; j--) { + if(slicers.get(j).getRect().intersects(r)){ + slicers.get(j).setHealth(slicers.get(j).getHealth()-v.getDamage()); + } + } + } + // Remove plane + if (v.isFinished()) { + planes.remove(i); } - - // Remove projectile - projectiles.remove(i); } } + // Update all slicers + for (int i = slicers.size() - 1; i >= 0; i--) { + if(!slicers.isEmpty()){ + Slicer s = slicers.get(i); + + s.update(input); + // Checks if specified slicer is finished + if (s.isFinished()) { + // Checks if slicer was finished by depleting health + if(s.getHealth()<=0){ + // Spawn slicers on death if so + if(s.getPenalty() == 2){ + for (int j = 0; j < s.getSpawnOnDeath(); j++) { + slicers.add(new RegularSlicer(polyline, s.getTargetPointIndex(), s.getCurrentPoint(), RSLICER)); + } + + } else if(s.getPenalty() == 4){ + for (int j = 0; j < s.getSpawnOnDeath(); j++) { + slicers.add(new SuperSlicer(polyline,s.getTargetPointIndex(),s.getCurrentPoint(),SSLICER)); + } + + } else if(s.getPenalty() == 16){ + for (int j = 0; j < s.getSpawnOnDeath(); j++) { + slicers.add(new MegaSlicer(polyline,s.getTargetPointIndex(),s.getCurrentPoint(),MSLICER)); + } - } - // Update all planes - for (int i = planes.size() - 1; i >= 0; i--) { - if(!planes.isEmpty()){ - Airplane v = planes.get(i); - v.update(input); - // Check if any of the plane's explosives are going to explode - if(v.getExplode()!=null){ - // One of the planes explosives is ready to explode - // Create a range for explosion to occur - Rectangle r = new Rectangle(v.getExplode().x-EXP_RADIUS, - v.getExplode().y-EXP_RADIUS, - EXP_RADIUS*2, - EXP_RADIUS*2); - // Remove appropriate health from all slicers in range - for (int j = slicers.size() - 1; j >= 0; j--) { - if(slicers.get(j).getRect().intersects(r)){ - slicers.get(j).setHealth(slicers.get(j).getHealth()-v.getDamage()); + } + // Update gold for slicer kill + gold += s.getReward(); + } else { + // Update lives if slicer completed the run + lives -= s.getPenalty(); } + // Remove slicer + slicers.remove(i); } + } - // Remove plane - if (v.isFinished()) { - planes.remove(i); - } - } + } + } else if(lives<=0){ + lives = 0; } - // Update all slicers - for (int i = slicers.size() - 1; i >= 0; i--) { - if(!slicers.isEmpty()){ - Slicer s = slicers.get(i); - - s.update(input); - // Checks if specified slicer is finished - if (s.isFinished()) { - // Checks if slicer was finished by depleting health - if(s.getHealth()<=0){ - // Spawn slicers on death if so - if(s.getPenalty() == 2){ - for (int j = 0; j < s.getSpawnOnDeath(); j++) { - slicers.add(new RegularSlicer(polyline, s.getTargetPointIndex(), s.getCurrentPoint(), RSLICER)); - } - } else if(s.getPenalty() == 4){ - for (int j = 0; j < s.getSpawnOnDeath(); j++) { - slicers.add(new SuperSlicer(polyline,s.getTargetPointIndex(),s.getCurrentPoint(),SSLICER)); - } - } else if(s.getPenalty() == 16){ - for (int j = 0; j < s.getSpawnOnDeath(); j++) { - slicers.add(new MegaSlicer(polyline,s.getTargetPointIndex(),s.getCurrentPoint(),MSLICER)); - } - } - // Update gold for slicer kill - gold += s.getReward(); - } else { - // Update lives if slicer completed the run - lives -= s.getPenalty(); - } - // Remove slicer - slicers.remove(i); - } - } - } + + //Draw shop panel drawShopPanel(); diff --git a/src/Slicer.java b/src/Slicer.java index 29a9f45a4590d3e4684de43eef963fe1d5b16252..cf9fbe4b6af8f919d7f18b849619fb511c50679a 100644 --- a/src/Slicer.java +++ b/src/Slicer.java @@ -4,11 +4,10 @@ import bagel.util.Vector2; import java.util.List; /** - * A regular slicer. + * A slicer template. */ public class Slicer extends Sprite { - protected double speed,reward,penalty; protected int health, spawnOnDeath; protected final List<Point> polyline; @@ -25,8 +24,6 @@ public class Slicer extends Sprite { this.polyline = polyline; this.targetPointIndex = targetPointIndex; this.finished = false; - - } public int getTargetPointIndex() { @@ -84,9 +81,8 @@ public class Slicer extends Sprite { targetPointIndex += 1; } } - + // Check if health remaining if(health<=0){ - finished = true; return; } diff --git a/src/SuperSlicer.java b/src/SuperSlicer.java index 03f7aec9c4875b1410437ea27c311b0f57074ea0..8890ab31d6fe41dafd8fe0379484dd04b7239318 100644 --- a/src/SuperSlicer.java +++ b/src/SuperSlicer.java @@ -18,7 +18,7 @@ public class SuperSlicer extends Slicer { public SuperSlicer(List<Point> polyline, int targetPointIndex, Point point,String imageSrc) { super(polyline,targetPointIndex,point, imageSrc); - this.speed = 0.75; + this.speed = 1.5; this.health = 1; this.reward = 15; this.penalty = 2; diff --git a/src/SuperTank.java b/src/SuperTank.java index 4202cbae2d69aeb1da34dfb2d15576d98bbcabf7..207d6e31afbeee5793b509e82147a9ef04ecc2bb 100644 --- a/src/SuperTank.java +++ b/src/SuperTank.java @@ -1,10 +1,16 @@ import bagel.Input; import bagel.util.Point; - +/** + * A super tank. + */ public class SuperTank extends Tank{ - + /** + * Creates a new Tank + * + * @param point The point where the image is to be drawn + */ public SuperTank(Point point, String imageSrc){ super(point,imageSrc); this.radius = 150; @@ -12,7 +18,9 @@ public class SuperTank extends Tank{ this.cooldown = 500; } - + /** + * Updates the current state of the tank. The tank faces its next target. + */ @Override public void update(Input input) { diff --git a/src/Tank.java b/src/Tank.java index 9a0e755c95c8901c6acf01ee8d8eac68d213bc58..f6fac57ce8d532e6919932edc5792c73dc6076ab 100644 --- a/src/Tank.java +++ b/src/Tank.java @@ -1,12 +1,19 @@ import bagel.Input; import bagel.util.Point; +/** + * A tank. + */ public class Tank extends Sprite{ protected double radius,cooldown; protected int damage; protected Point tankPoint; protected Slicer target; - + /** + * Creates a new Tank + * + * @param point The point where the image is to be drawn + */ public Tank(Point point, String imageSrc) { super(point, imageSrc); this.radius = 100; @@ -34,6 +41,9 @@ public class Tank extends Sprite{ public double getCooldown(){ return this.cooldown; } + /** + * Updates the current state of the tank. The tank faces its next target. + */ @Override public void update(Input input) { if(target != null){