|
@ -53,7 +53,6 @@ public class Tanks |
|
|
@Override |
|
|
@Override |
|
|
public void keyTyped(KeyEvent e) |
|
|
public void keyTyped(KeyEvent e) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
@Override |
|
|
@Override |
|
|
public void keyPressed(KeyEvent e) |
|
|
public void keyPressed(KeyEvent e) |
|
@ -104,6 +103,10 @@ public class Tanks |
|
|
g.setFont(new Font("Arial" , 1, 25)); |
|
|
g.setFont(new Font("Arial" , 1, 25)); |
|
|
g.drawString("Wave: " + wave.waveNum, 50, fheight + 50); |
|
|
g.drawString("Wave: " + wave.waveNum, 50, fheight + 50); |
|
|
|
|
|
|
|
|
|
|
|
g.setColor(Color.WHITE); |
|
|
|
|
|
g.setFont(new Font("Arial" , 1, 25)); |
|
|
|
|
|
g.drawString("Ammo: "+ p.ammo, 150, fheight+50); |
|
|
|
|
|
|
|
|
//Kills |
|
|
//Kills |
|
|
g.setColor(Color.WHITE); |
|
|
g.setColor(Color.WHITE); |
|
|
g.setFont(new Font("Arial" , 1, 25)); |
|
|
g.setFont(new Font("Arial" , 1, 25)); |
|
@ -211,9 +214,27 @@ public class Tanks |
|
|
{ |
|
|
{ |
|
|
private Turret t; |
|
|
private Turret t; |
|
|
private boolean up,down,left,right, rleft, rRight; |
|
|
private boolean up,down,left,right, rleft, rRight; |
|
|
|
|
|
private int ammo=10; |
|
|
|
|
|
private boolean shoot; |
|
|
|
|
|
ActionListener coolDown = new ActionListener() |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
|
if(shoot==false) |
|
|
|
|
|
{ |
|
|
|
|
|
shoot=true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
Timer time=new Timer(300,coolDown); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Player() |
|
|
public Player() |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
time.start(); |
|
|
t=new Turret(this); |
|
|
t=new Turret(this); |
|
|
speed = 5; |
|
|
speed = 5; |
|
|
x = frame.getWidth()/2; |
|
|
x = frame.getWidth()/2; |
|
@ -303,24 +324,47 @@ public class Tanks |
|
|
{ |
|
|
{ |
|
|
rRight = pressed; |
|
|
rRight = pressed; |
|
|
} |
|
|
} |
|
|
|
|
|
else if(id==KeyEvent.VK_R) |
|
|
|
|
|
{ |
|
|
|
|
|
ammo=10; |
|
|
|
|
|
} |
|
|
else if(id==KeyEvent.VK_SPACE) |
|
|
else if(id==KeyEvent.VK_SPACE) |
|
|
{ |
|
|
{ |
|
|
if(pressed) |
|
|
if(pressed) |
|
|
{ |
|
|
{ |
|
|
shoot(); |
|
|
|
|
|
|
|
|
if (shoot) |
|
|
|
|
|
{ |
|
|
|
|
|
shoot(); |
|
|
|
|
|
shoot=false; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
void shoot() |
|
|
void shoot() |
|
|
{ |
|
|
{ |
|
|
bullets.add(new Bullet (t)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(ammo<=0) |
|
|
|
|
|
{ |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
bullets.add(new Bullet (t)); |
|
|
|
|
|
ammo--; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
public void draw (Graphics g) |
|
|
public void draw (Graphics g) |
|
|
{ |
|
|
{ |
|
|
super.draw(g); |
|
|
super.draw(g); |
|
|
t.draw(g); |
|
|
t.draw(g); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|