Commit 765ef2aa authored by nargessalehi98's avatar nargessalehi98

Add new Counter.

parent 037f5bb1
...@@ -18,10 +18,14 @@ public class Tank { ...@@ -18,10 +18,14 @@ public class Tank {
boolean laser; boolean laser;
boolean bullet2; boolean bullet2;
boolean bullet3; boolean bullet3;
int shieldCounter;
int laserCounter;
public Tank(String path, int x, int y, double rotateAmount) { public Tank(String path, int x, int y, double rotateAmount) {
prize="empty"; prize = "empty";
Health = 100; Health = Controller.tankHealth;
shieldCounter = 0;
laserCounter = 0;
try { try {
icon = ImageIO.read(new File(path)); icon = ImageIO.read(new File(path));
} catch (IOException e) { } catch (IOException e) {
...@@ -55,7 +59,8 @@ public class Tank { ...@@ -55,7 +59,8 @@ public class Tank {
} }
public void setHealth(int healthDamage) { public void setHealth(int healthDamage) {
Health = Health - healthDamage; Health -= healthDamage;
if (Health <= 0) Health = 0;
} }
public String getPrize() { public String getPrize() {
...@@ -67,30 +72,42 @@ public class Tank { ...@@ -67,30 +72,42 @@ public class Tank {
} }
public void applyPrize() { public void applyPrize() {
if(!prize.equals("empty")) { if (!prize.equals("empty")) {
if (prize.equals("life")) if (prize.equals("life")) {
Health += 10; Health += 10;
// if (Health > 100) }
// Health = 100; if (Health > 100) {
Health = 100;
}
if (prize.equals("shield")) { if (prize.equals("shield")) {
if (Controller.renderCountLimit - 50 == Controller.renderCount) if (shieldCounter < 150) {
bulletEffect = true; bulletEffect = true;
else shieldCounter++;
} else {
shieldCounter = 160;
bulletEffect = false; bulletEffect = false;
} }
}
if (prize.equals("bullet2")) { if (prize.equals("bullet2")) {
if (!bullet2)
bullet2 = true; bullet2 = true;
Controller.bulletSpeed = 6;
} }
if (prize.equals("bullet3")) { if (prize.equals("bullet3")) {
if (!bullet3)
bullet3 = true; bullet3 = true;
Controller.bulletSpeed = 9;
} }
if (prize.equals("laser")) { if (prize.equals("laser")) {
if (Controller.renderCountLimit - 410 == Controller.renderCount) Controller.laser = laser;
laser = false; if (laserCounter < 120) {
else
laser = true; laser = true;
Controller.laser = true;
Controller.bulletSpeed = 9;
laserCounter++;
} else {
laserCounter = 130;
Controller.laser = false;
Controller.bulletSpeed = 4;
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment