Browse Source

class declarations

pull/1/head
jrtechs 8 years ago
parent
commit
08528ed41d
2 changed files with 74 additions and 23 deletions
  1. +8
    -5
      src/tanks/RotationalElement.java
  2. +66
    -18
      src/tanks/Tanks.java

+ 8
- 5
src/tanks/RotationalElement.java View File

@ -17,6 +17,9 @@ public abstract class RotationalElement extends GameElement
//0-360 angle which determines which direction the object is facing //0-360 angle which determines which direction the object is facing
public double direction; public double direction;
//integer which defines how fast a object will move
public int speed;
//convertes degrease to radians //convertes degrease to radians
public double degToRad() public double degToRad()
{ {
@ -32,14 +35,13 @@ public abstract class RotationalElement extends GameElement
/* /*
moves the object's x and y according to its degrees moves the object's x and y according to its degrees
the multiplier is used to move at a specific speed the multiplier is used to move at a specific speed
a positive multiplier moves the object backwards
a negative multiplier moves the object forwards
a positive multiplier(1) moves the object backwards
a negative multiplier(-1) moves the object forwards
*/ */
public void move(int multiplier) public void move(int multiplier)
{ {
y += Math.sin(degToRad()) * multiplier;
x += Math.cos(degToRad()) * multiplier;
y += Math.sin(degToRad()) * multiplier * speed;
x += Math.cos(degToRad()) * multiplier * speed;
} }
/* /*
@ -57,6 +59,7 @@ public abstract class RotationalElement extends GameElement
//draws the rotated image on the panel //draws the rotated image on the panel
((Graphics2D)(g)).drawImage(img, tf, null); ((Graphics2D)(g)).drawImage(img, tf, null);
} }
/* /*
Sets the area variable shape in GameElement to be used in collision code Sets the area variable shape in GameElement to be used in collision code
*/ */

+ 66
- 18
src/tanks/Tanks.java View File

@ -1,48 +1,96 @@
/*
Set 3 programming project
5-18-16
*****************Tanks***************
https://github.com/jrtechs/Tanks/wiki
*/
package tanks; package tanks;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
/**
*
* Set 3 class project
* 5-19-16
*
*/
public class Tanks public class Tanks
{ {
//fields //fields
private JFrame f;
private JFrame frame;
private JPanel panel; private JPanel panel;
private int kills;
//constructor //constructor
public Tanks() public Tanks()
{ {
//this is a test by bryce
//this is a test push by Matt
//this is a push by Mike R
} }
private class Player extends RotationalElement
//creates a new instance of tanks to run
public static void main(String[] arguments)
{ {
//This is a test by emily
Tanks runnable = new Tanks();
} }
private abstract class Enemy extends RotationalElement
/*
Sub-classes that require the fields in tanks
*/
/*
the player class which extends the living class
a player has a turret and an int kills
a player has a specialized move method
a player has a update direction method which takes in a keyevent
*/
private class Player extends Living
{ {
//this is a test by nick
} }
/*
A zombie extends Enemy
a zombie has a specialized move method which
moves it twards the player
the move method checks to see if it collides with the player
if so it removes itself from the arraylist in tanks and deducts damage
*/
private class Zombie extends Enemy private class Zombie extends Enemy
{ {
} }
/*
a bullet moves at a specified angle
if the bullet collides with a enemy it gives damage
if the bullet goes off the screen it removes itself from the arraylist
*/
private class Bullet extends RotationalElement private class Bullet extends RotationalElement
{ {
} }
//creates a new instance of tanks to run
public static void main(String[] arguments)
/*
a turret is drawn ontop of the tank
a turret can rotate and shoot bullets
*/
private class Turret extends RotationalElement
{ {
Tanks runnable = new Tanks();
}
/*
*/
private class Tank extends Enemy
{
} }
} }

Loading…
Cancel
Save