Browse Source

added wave, zombie image

update shape creation code
pull/1/head
jrtechs 8 years ago
parent
commit
69e593c49c
5 changed files with 18 additions and 16 deletions
  1. +2
    -1
      src/tanks/DrawableElement.java
  2. +2
    -2
      src/tanks/RotationalElement.java
  3. +14
    -13
      src/tanks/Tanks.java
  4. BIN
      src/tanks/wave.jpg
  5. BIN
      src/tanks/zombie.png

+ 2
- 1
src/tanks/DrawableElement.java View File

@ -32,12 +32,13 @@ public abstract class DrawableElement
img = null;
try
{
System.out.println(imageLocation);
img = ImageIO.read(getClass().getResourceAsStream(imageLocation));
//img = ImageIO.read(new File(imageLoc));
}
catch(IOException e)
{
System.out.println(e.toString());
//System.out.println(e.toString());
}
}
}

+ 2
- 2
src/tanks/RotationalElement.java View File

@ -66,8 +66,8 @@ public abstract class RotationalElement extends GameElement
@Override
public void setShape()
{
AffineTransform rotate = AffineTransform.getRotateInstance(degToRad(), x, y);
AffineTransform rotate = AffineTransform.getRotateInstance(degToRad(), x + width /2, y + height /2);
shape = new Area(rotate.createTransformedShape(new Rectangle(x,y,width, height)));
shape = new Area(rotate.createTransformedShape(new Rectangle(x,y ,width, height)));
}
}

+ 14
- 13
src/tanks/Tanks.java View File

@ -23,8 +23,8 @@ public class Tanks
//fields
private JFrame frame;
private JPanel panel;
private int fheight=500;
private int fwidth=800;
private int fheight=650;
private int fwidth=900;
private Timer move;
private KeyListener key;
@ -229,7 +229,10 @@ public class Tanks
}
else if(id==KeyEvent.VK_SPACE)
{
shoot();
if(pressed)
{
shoot();
}
}
}
@ -261,7 +264,7 @@ public class Tanks
health = 10;
isAlive=true;
speed = 3;
imageLocation = "player.png";
imageLocation = "zombie.png";
super.loadImage();
}
//uses super to move player if collision then removes zombie and player
@ -397,7 +400,10 @@ public class Tanks
gameMode=1;
waveNum=1;
//actionlistener calls spawn every 2 seconds
imageLocation = "wave.jpg";
super.loadImage();
//actionlistener calls spawn every 2 seconds
ActionListener s = new ActionListener()
{
@ -429,11 +435,6 @@ public class Tanks
{
newGameMode=gameMode;
}
public void draw(Graphics g)
{
g.setColor(Color.yellow);
g.fillRect(0, 0, 500, 500);
}
//spawn method checks if spawn timer ==0 and if so then spawns an
@ -441,9 +442,9 @@ public class Tanks
public void spawn()
{
Enemy temp = new Zombie();
temp.spawn(frame);
enemy.add(temp);
Enemy temp = new Zombie();
temp.spawn(frame);
enemy.add(temp);
}

BIN
src/tanks/wave.jpg View File

Before After
Width: 900  |  Height: 650  |  Size: 558 KiB

BIN
src/tanks/zombie.png View File

Before After
Width: 30  |  Height: 30  |  Size: 2.5 KiB

Loading…
Cancel
Save