Browse Source

main class fixes

added wave field
pull/1/head
jrtechs 8 years ago
parent
commit
0dcd6c689c
1 changed files with 9 additions and 8 deletions
  1. +9
    -8
      src/tanks/Tanks.java

+ 9
- 8
src/tanks/Tanks.java View File

@ -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);

Loading…
Cancel
Save