public abstract class AbstractGameObject extends java.lang.Object implements GameObject
Modifier and Type | Field and Description |
---|---|
static javax.swing.JPanel |
panel |
Constructor and Description |
---|
AbstractGameObject(int healthPoints,
java.lang.String imageLocation)
This constructor creates a game object with given HP and sprite location
|
Modifier and Type | Method and Description |
---|---|
void |
draw(java.awt.Graphics2D g2d)
This method draws the object.
|
java.awt.geom.Point2D.Double |
getCenter()
This method gets the center as a point.
|
java.awt.geom.Point2D.Double |
getDirection()
This method gets the direction as a point.
|
int |
getHealthPoints()
This method returns the number of HP.
|
double |
getHeight()
This method gets the height of the sprite.
|
java.awt.image.BufferedImage |
getImage()
This method gets the sprite (BufferedImage).
|
java.awt.geom.Point2D.Double |
getPosition()
This method get the position.
|
double |
getWidth()
This method gets the width of the sptie.
|
double |
getXCenter()
This method gets the center on x-axis.
|
double |
getXDirection()
This method get the directoin on x-axis.
|
double |
getXPosition()
This method get the position on x-axis.
|
double |
getXVelocity()
This method get the velocity on x-axis.
|
double |
getYCenter()
This method get the center on y-axis.
|
double |
getYDirection()
This method get the directoin on y-axis.
|
double |
getYPosition()
This method get the position on y-axis.
|
double |
getYVelocity()
This method get the velocity on y-axis.
|
void |
gotHit()
This method is called if the object got hit, decreasing it's HP by 1.
|
abstract void |
initializeLocation()
This method is called when a game object is created and is ready to be given a location on a panel.
|
boolean |
isDead()
This method checks if an object is dead.
|
void |
makeDead()
This method makes te object dead.
|
void |
move()
This method moves the object.
|
abstract void |
moveDirection()
This method moves the object only in terms of direction (rotation).
|
abstract void |
movePosition()
This method moves the object only in term of position.
|
void |
setDirection(java.awt.geom.Point2D location)
This method sets the direction from a point.
|
void |
setDirectionToward(java.awt.geom.Point2D location)
This method sets the directoin toward a point.
|
void |
setHealthPoints(int helathPoints)
This method sets the number of HP.
|
void |
setImage(java.awt.image.BufferedImage image)
This method sets the sprite (BufferedImage).
|
void |
setImageLocation(java.lang.String imageLocation)
This method sets the sprite given the location of the image.
|
void |
setPosition(java.awt.geom.Point2D.Double point)
This method sets the position.
|
void |
setXDirection(double xDirection)
This method sets the directoin on x-axis.
|
void |
setXPosition(double xPosition)
This method sets the position on x-axis.
|
void |
setXVelocity(double xVelocity)
This method sets the velocity on x-axis.
|
void |
setYDirection(double yDirection)
This method sets the directoin on y-axis.
|
void |
setYPosition(double yPosition)
This method sets the position on y-axis.
|
void |
setYVelocity(double yVelocity)
This method sets the velocity on y-axis.
|
public AbstractGameObject(int healthPoints, java.lang.String imageLocation)
healthPoints
- the HP of the game objectimageLocation
- the location of the spritepublic void draw(java.awt.Graphics2D g2d)
draw
in interface GameObject
g2d
- the Graphics2D to do the drawingpublic void move()
move
in interface GameObject
public abstract void movePosition()
GameObject
movePosition
in interface GameObject
public abstract void moveDirection()
GameObject
moveDirection
in interface GameObject
public abstract void initializeLocation()
GameObject
initializeLocation
in interface GameObject
public double getXPosition()
GameObject
getXPosition
in interface GameObject
public void setXPosition(double xPosition)
GameObject
setXPosition
in interface GameObject
xPosition
- the position on x-axispublic double getYPosition()
GameObject
getYPosition
in interface GameObject
public void setYPosition(double yPosition)
GameObject
setYPosition
in interface GameObject
yPosition
- the position on y-axispublic java.awt.geom.Point2D.Double getPosition()
GameObject
getPosition
in interface GameObject
public void setPosition(java.awt.geom.Point2D.Double point)
GameObject
setPosition
in interface GameObject
point
- the positionpublic double getXVelocity()
GameObject
getXVelocity
in interface GameObject
public void setXVelocity(double xVelocity)
GameObject
setXVelocity
in interface GameObject
xVelocity
- the velocity on x-axispublic double getYVelocity()
GameObject
getYVelocity
in interface GameObject
public void setYVelocity(double yVelocity)
GameObject
setYVelocity
in interface GameObject
yVelocity
- the velocity on y-axispublic double getXDirection()
GameObject
getXDirection
in interface GameObject
public void setXDirection(double xDirection)
GameObject
setXDirection
in interface GameObject
xDirection
- the direction on x-axispublic double getYDirection()
GameObject
getYDirection
in interface GameObject
public void setYDirection(double yDirection)
GameObject
setYDirection
in interface GameObject
yDirection
- the direction on y-axispublic void setDirection(java.awt.geom.Point2D location)
GameObject
setDirection
in interface GameObject
location
- a point containing the directionpublic java.awt.geom.Point2D.Double getDirection()
GameObject
getDirection
in interface GameObject
public void setDirectionToward(java.awt.geom.Point2D location)
setDirectionToward
in interface GameObject
location
- a point containing the location of a point to set direction topublic double getWidth()
GameObject
getWidth
in interface GameObject
public double getHeight()
GameObject
getHeight
in interface GameObject
public double getXCenter()
GameObject
getXCenter
in interface GameObject
public double getYCenter()
GameObject
getYCenter
in interface GameObject
public java.awt.geom.Point2D.Double getCenter()
GameObject
getCenter
in interface GameObject
public void gotHit()
gotHit
in interface GameObject
public boolean isDead()
isDead
in interface GameObject
public void makeDead()
makeDead
in interface GameObject
public java.awt.image.BufferedImage getImage()
GameObject
getImage
in interface GameObject
public void setImage(java.awt.image.BufferedImage image)
GameObject
setImage
in interface GameObject
image
- the BufferedImage to be set as spritepublic void setImageLocation(java.lang.String imageLocation)
GameObject
setImageLocation
in interface GameObject
imageLocation
- the path to the imagepublic int getHealthPoints()
GameObject
getHealthPoints
in interface GameObject
public void setHealthPoints(int helathPoints)
GameObject
setHealthPoints
in interface GameObject
helathPoints
- the number to set the HP as