Browse Source

Rearranged case statments and moved assets to its own file

TryingToMakeThisALittleBetter
Michael 5 years ago
parent
commit
e9ca94aecc
9 changed files with 37 additions and 63 deletions
  1. +29
    -63
      src/tanks/Tanks.java
  2. +8
    -0
      src/tanks/TanksMain.java
  3. +0
    -0
      src/tanks/assets/bullet.png
  4. +0
    -0
      src/tanks/assets/enemyTank.png
  5. +0
    -0
      src/tanks/assets/enemyTurret.png
  6. +0
    -0
      src/tanks/assets/player.png
  7. +0
    -0
      src/tanks/assets/turret.png
  8. +0
    -0
      src/tanks/assets/wave.jpg
  9. +0
    -0
      src/tanks/assets/zombie.png

+ 29
- 63
src/tanks/Tanks.java View File

@ -181,24 +181,24 @@ public class Tanks
} }
}; };
Timer time=new Timer(300,coolDown); Timer time=new Timer(300,coolDown);
public Player() public Player()
{ {
x = frame.getWidth()/2; x = frame.getWidth()/2;
y = frame.getHeight()/2; y = frame.getHeight()/2;
time.start(); time.start();
t=new Turret(this); t=new Turret(this);
speed = 5; speed = 5;
health = 100; health = 100;
this.imageLocation = "player.png";
this.imageLocation = "assets\\player.png";
super.loadImage(); super.loadImage();
width = 50; width = 50;
height = 50; height = 50;
} }
void move() { void move() {
if(rleft) { if(rleft) {
t.rotate(-1); t.rotate(-1);
@ -299,7 +299,7 @@ public class Tanks
health = 10; health = 10;
isAlive=true; isAlive=true;
speed = 3; speed = 3;
imageLocation = "zombie.png";
imageLocation = "assets\\zombie.png";
super.loadImage(); super.loadImage();
} }
//uses super to move player if collision then removes zombie and player //uses super to move player if collision then removes zombie and player
@ -336,7 +336,7 @@ public class Tanks
y = e.y + 12; y = e.y + 12;
direction = e.direction; direction = e.direction;
speed = 10; speed = 10;
imageLocation = "bullet.png";
imageLocation = "assets\bullet.png";
super.loadImage(); super.loadImage();
} }
@ -398,7 +398,7 @@ public class Tanks
y = e.y; y = e.y;
direction = e.direction; direction = e.direction;
speed = 10; speed = 10;
imageLocation = "turret.png";
imageLocation = "assets\\turret.png";
super.loadImage(); super.loadImage();
} }
@ -425,11 +425,11 @@ public class Tanks
health = 20; health = 20;
isAlive=true; isAlive=true;
speed = 2; speed = 2;
imageLocation = "enemyTank.png";
imageLocation = "assets\\enemyTank.png";
super.loadImage(); super.loadImage();
t = new Turret(this); t = new Turret(this);
t.imageLocation = "enemyTurret.png";
t.imageLocation = "assets\\enemyTurret.png";
t.loadImage(); t.loadImage();
al = e -> { al = e -> {
@ -493,14 +493,10 @@ public class Tanks
super.loadImage(); super.loadImage();
//actionlistener calls spawn every 2 seconds //actionlistener calls spawn every 2 seconds
ActionListener z = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(gameMode == 1) {
spawnZombie();
}
ActionListener z = e -> {
if(gameMode == 1) {
spawnZombie();
} }
}; };
ActionListener ta = e -> { ActionListener ta = e -> {
@ -512,13 +508,9 @@ public class Tanks
spawnTank = new Timer(2000,ta); spawnTank = new Timer(2000,ta);
spawnZombie = new Timer(2000, z); spawnZombie = new Timer(2000, z);
spawnZombie.start(); spawnZombie.start();
ActionListener t = new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e) {
if(gameMode==1) {
timeCount++;
}
ActionListener t = e -> {
if(gameMode==1) {
timeCount++;
} }
}; };
time = new Timer(1000,t); time = new Timer(1000,t);
@ -551,19 +543,15 @@ public class Tanks
enemy.add(new Zombie()); enemy.add(new Zombie());
spawnedZombies++; spawnedZombies++;
} }
public void waveCheck()
{
if(gameMode == 1)
{
switch(waveNum)
{
case 1:
public void waveCheck() {
if(gameMode == 1) {
switch(waveNum) {
case 1: case 2: case 4:
if(kills == 15) { if(kills == 15) {
changeWave(); changeWave();
}
break;
case 2:
if(kills == 20) {
}else if(kills == 20) {
changeWave();
}else if(kills == 32) {
changeWave(); changeWave();
} }
break; break;
@ -573,39 +561,21 @@ public class Tanks
changeWave(); changeWave();
} }
break; break;
case 4:
if(kills == 32) {
changeWave();
}
break;
case 5:
case 5: case 6: case 7: case 8: case 9:
if(kills == 33) { if(kills == 33) {
changeWave(); changeWave();
}
break;
case 6:
if(kills == 35) {
} else if(kills == 35) {
changeWave(); changeWave();
}
break;
case 7:
if(kills == 37) {
}else if(kills == 37) {
changeWave(); changeWave();
}
break;
case 8:
if(kills == 40) {
} else if(kills == 40) {
changeWave(); changeWave();
}
break;
case 9:
if(kills == 49) {
} else if(kills == 49) {
changeWave(); changeWave();
} }
break; break;
case 10: case 10:
if(kills == 60)
{
if(kills == 60) {
//Game over //Game over
} }
break; break;
@ -620,9 +590,5 @@ public class Tanks
spawnTank.setDelay(4000); spawnTank.setDelay(4000);
} }
} }
//Main method
public static void main(String[] arguments) {
Tanks game = new Tanks();
}
} }

+ 8
- 0
src/tanks/TanksMain.java View File

@ -0,0 +1,8 @@
package tanks;
public class TanksMain {
//Main method
public static void main(String[] arguments) {
Tanks game = new Tanks();
}
}

src/tanks/bullet.png → src/tanks/assets/bullet.png View File


src/tanks/enemyTank.png → src/tanks/assets/enemyTank.png View File


src/tanks/enemyTurret.png → src/tanks/assets/enemyTurret.png View File


src/tanks/player.png → src/tanks/assets/player.png View File


src/tanks/turret.png → src/tanks/assets/turret.png View File


src/tanks/wave.jpg → src/tanks/assets/wave.jpg View File


src/tanks/zombie.png → src/tanks/assets/zombie.png View File


Loading…
Cancel
Save