From 92276dfc402191527f985127514b5da0bee74c6f Mon Sep 17 00:00:00 2001 From: 17bthompson Date: Mon, 23 May 2016 10:32:06 -0400 Subject: [PATCH] Created Bullet Class --- src/tanks/Tanks.java | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/tanks/Tanks.java b/src/tanks/Tanks.java index 1b711c9..75e6f6b 100644 --- a/src/tanks/Tanks.java +++ b/src/tanks/Tanks.java @@ -9,12 +9,14 @@ package tanks; import javax.swing.JFrame; import javax.swing.JPanel; +import java.util.ArrayList; public class Tanks { //fields private JFrame frame; private JPanel panel; + private ArrayList bullets; //constructor public Tanks() @@ -74,6 +76,33 @@ public class Tanks private class Bullet extends RotationalElement { + public Bullet(RotationalElement e) + { + x = e.x; //Change this coordinate to the player's location + y = e.y; //Change this coordinate to the player's location + direction = e.direction; //Change this coordinate to the player turret's angle + speed = 10; + } + + //Moving the bullet + public void move() + { + super.move(-1); + + //Checks if the bullet goes off screen, if so... it get removed + if(x < 0 || x > frame.getHeight()) + { + bullets.remove(this); //Jeff does this work? + } + if (y < 0 || y > frame.getWidth()) + { + bullets.remove(this); //" " + } + } + + + + } /*