public abstract class Unit extends GameObject
| Modifier and Type | Field and Description |
|---|---|
boolean |
falling
Identifies if the unit is falling
|
double |
xSpeed
Stores the x speed
|
double |
ySpeed
Stores the y speed
|
| Constructor and Description |
|---|
Unit()
The default constructor
|
Unit(double x,
double y,
int xDir,
int yDir,
double xSpeed,
double ySpeed,
double w,
double h)
The general constructor used to create the unit
|
| Modifier and Type | Method and Description |
|---|---|
java.awt.geom.Line2D |
getBottomContactLine()
Gets the bottom contact line of the unit's hitbox
|
java.awt.Rectangle |
getBoundary()
Gets the rectangular boundary of the unit's hitbox
|
java.awt.geom.Line2D |
getCenterHorizontalContactLine()
Gets the horizontal, center contact line of the unit's hitbox
|
java.awt.geom.Line2D |
getCenterVerticalContactLine()
Gets the vertical, center contact line of the unit's hitbox
|
java.awt.geom.Line2D |
getContactLine()
Gets the top contact line of the unit's hitbox
|
java.awt.geom.Line2D |
getLeftContactLine()
Gets the left contact line of the unit's hitbox
|
java.awt.geom.Line2D |
getRightContactLine()
Gets the right contact line of the unit's hitbox
|
abstract void |
interact(GameObject gameObject)
Describes the interation between the unit and a game object
|
abstract void |
paint(java.awt.Graphics g)
Paints the unit
|
abstract void |
update()
Updates the unit
|
changeXDir, changeYDirpublic double xSpeed
public double ySpeed
public boolean falling
public Unit()
public Unit(double x,
double y,
int xDir,
int yDir,
double xSpeed,
double ySpeed,
double w,
double h)
x - The spawning x coordinatey - The spawning y coordinatexDir - The spawning x directionyDir - The spawning y directionxSpeed - The spawning x speedySpeed - The spawning y speedw - The spawning widthh - The spawning heightpublic java.awt.geom.Line2D getContactLine()
getContactLine in class GameObjectpublic java.awt.geom.Line2D getRightContactLine()
public java.awt.geom.Line2D getBottomContactLine()
public java.awt.geom.Line2D getLeftContactLine()
public java.awt.geom.Line2D getCenterVerticalContactLine()
public java.awt.geom.Line2D getCenterHorizontalContactLine()
public java.awt.Rectangle getBoundary()
public abstract void paint(java.awt.Graphics g)
paint in class GameObjectg - An instance of the Graphics objectpublic abstract void update()
update in class GameObjectpublic abstract void interact(GameObject gameObject)
interact in class GameObjectgameObject - The game object that the unit is interacting with