|
@ -23,11 +23,15 @@ public class Tanks |
|
|
private JFrame frame; |
|
|
private JFrame frame; |
|
|
private JPanel panel; |
|
|
private JPanel panel; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Timer move; |
|
|
|
|
|
private KeyListener key; |
|
|
|
|
|
|
|
|
//game elements |
|
|
//game elements |
|
|
private ArrayList<Bullet> bullets; |
|
|
private ArrayList<Bullet> bullets; |
|
|
private Player p; |
|
|
private Player p; |
|
|
private ArrayList<Enemy> enemy; |
|
|
private ArrayList<Enemy> enemy; |
|
|
Timer move; |
|
|
|
|
|
|
|
|
private Wave wave; |
|
|
|
|
|
|
|
|
//constructor |
|
|
//constructor |
|
|
public Tanks() |
|
|
public Tanks() |
|
@ -37,7 +41,7 @@ public class Tanks |
|
|
frame=new JFrame("Tanks project"); |
|
|
frame=new JFrame("Tanks project"); |
|
|
frame.setSize(500,500); |
|
|
frame.setSize(500,500); |
|
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
|
KeyListener key=new KeyListener() |
|
|
|
|
|
|
|
|
key=new KeyListener() |
|
|
{ |
|
|
{ |
|
|
@Override |
|
|
@Override |
|
|
public void keyTyped(KeyEvent e) |
|
|
public void keyTyped(KeyEvent e) |
|
@ -47,17 +51,15 @@ public class Tanks |
|
|
public void keyPressed(KeyEvent e) |
|
|
public void keyPressed(KeyEvent e) |
|
|
{ |
|
|
{ |
|
|
p.updateDir(e, true); |
|
|
p.updateDir(e, true); |
|
|
panel.repaint(); |
|
|
|
|
|
} |
|
|
} |
|
|
@Override |
|
|
@Override |
|
|
public void keyReleased(KeyEvent e) { |
|
|
|
|
|
|
|
|
public void keyReleased(KeyEvent e) |
|
|
|
|
|
{ |
|
|
p.updateDir(e, false); |
|
|
p.updateDir(e, false); |
|
|
panel.repaint(); |
|
|
|
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
frame.addKeyListener(key); |
|
|
frame.addKeyListener(key); |
|
|
|
|
|
|
|
|
System.out.println("Mrs. Shaw test"); |
|
|
|
|
|
panel = new JPanel() |
|
|
panel = new JPanel() |
|
|
{ |
|
|
{ |
|
|
protected void paintComponent(Graphics g) |
|
|
protected void paintComponent(Graphics g) |
|
@ -195,7 +197,6 @@ public class Tanks |
|
|
this.spawn(frame); |
|
|
this.spawn(frame); |
|
|
width = 30; |
|
|
width = 30; |
|
|
height = 30; |
|
|
height = 30; |
|
|
this.setShape(); |
|
|
|
|
|
health = 10; |
|
|
health = 10; |
|
|
isAlive=true; |
|
|
isAlive=true; |
|
|
} |
|
|
} |
|
@ -339,7 +340,7 @@ public class Tanks |
|
|
public void spawn() |
|
|
public void spawn() |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
Enemy temp = new Enemy(); |
|
|
|
|
|
|
|
|
Enemy temp = new Zombie(); |
|
|
temp.spawn(frame); |
|
|
temp.spawn(frame); |
|
|
enemy.add(temp); |
|
|
enemy.add(temp); |
|
|
|
|
|
|
|
|