|
@ -43,7 +43,7 @@ public class Tanks |
|
|
|
|
|
|
|
|
frame=new JFrame("Tanks project"); |
|
|
frame=new JFrame("Tanks project"); |
|
|
frame.setSize(fwidth,fheight + 150); |
|
|
frame.setSize(fwidth,fheight + 150); |
|
|
//frame.setResizable(false); |
|
|
|
|
|
|
|
|
frame.setResizable(false); |
|
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
|
|
|
|
|
|
|
newGame(); |
|
|
newGame(); |
|
@ -340,7 +340,7 @@ public class Tanks |
|
|
public Zombie() |
|
|
public Zombie() |
|
|
{ |
|
|
{ |
|
|
super(); |
|
|
super(); |
|
|
this.spawn(frame); |
|
|
|
|
|
|
|
|
spawn(fwidth, fheight); |
|
|
width = 30; |
|
|
width = 30; |
|
|
height = 30; |
|
|
height = 30; |
|
|
health = 10; |
|
|
health = 10; |
|
@ -399,11 +399,11 @@ public class Tanks |
|
|
super.move(-1); |
|
|
super.move(-1); |
|
|
|
|
|
|
|
|
//Checks if the bullet goes off screen, if so... it get removed |
|
|
//Checks if the bullet goes off screen, if so... it get removed |
|
|
if(x < 0 || x > frame.getWidth()) |
|
|
|
|
|
|
|
|
if(x < 0 || x > fwidth) |
|
|
{ |
|
|
{ |
|
|
bullets.remove(this); |
|
|
bullets.remove(this); |
|
|
} |
|
|
} |
|
|
if (y < 0 || y > frame.getHeight()) |
|
|
|
|
|
|
|
|
if (y < 0 || y > fheight) |
|
|
{ |
|
|
{ |
|
|
bullets.remove(this); |
|
|
bullets.remove(this); |
|
|
} |
|
|
} |
|
@ -489,7 +489,7 @@ public class Tanks |
|
|
{ |
|
|
{ |
|
|
super(); |
|
|
super(); |
|
|
enemy.add(this); |
|
|
enemy.add(this); |
|
|
this.spawn(frame); |
|
|
|
|
|
|
|
|
this.spawn(fwidth, fheight); |
|
|
width = 50; |
|
|
width = 50; |
|
|
height = 50; |
|
|
height = 50; |
|
|
health = 20; |
|
|
health = 20; |
|
@ -554,7 +554,7 @@ public class Tanks |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private class Wave extends DrawableElement |
|
|
|
|
|
|
|
|
private class Wave extends DrawableElement |
|
|
{ |
|
|
{ |
|
|
/*fields time is continous while playing, gameMode(1=playing, |
|
|
/*fields time is continous while playing, gameMode(1=playing, |
|
|
2=paused, 3=menu. spawntime keeps a countdown until next spawn, |
|
|
2=paused, 3=menu. spawntime keeps a countdown until next spawn, |
|
@ -587,7 +587,7 @@ public class Tanks |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
//action listener increments time |
|
|
//action listener increments time |
|
|
spawn = new Timer(2000,s); |
|
|
|
|
|
|
|
|
spawn = new Timer(5000,s); |
|
|
spawn.start(); |
|
|
spawn.start(); |
|
|
ActionListener t = new ActionListener() |
|
|
ActionListener t = new ActionListener() |
|
|
{ |
|
|
{ |
|
@ -622,10 +622,7 @@ public class Tanks |
|
|
//enemy |
|
|
//enemy |
|
|
public void spawn() |
|
|
public void spawn() |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
Enemy temp = new Zombie(); |
|
|
|
|
|
temp.spawn(frame); |
|
|
|
|
|
enemy.add(temp); |
|
|
|
|
|
|
|
|
enemy.add(new Zombie()); |
|
|
enemy.add(new Tank()); |
|
|
enemy.add(new Tank()); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|