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 GameObjectg2d - the Graphics2D to do the drawingpublic void move()
move in interface GameObjectpublic abstract void movePosition()
GameObjectmovePosition in interface GameObjectpublic abstract void moveDirection()
GameObjectmoveDirection in interface GameObjectpublic abstract void initializeLocation()
GameObjectinitializeLocation in interface GameObjectpublic double getXPosition()
GameObjectgetXPosition in interface GameObjectpublic void setXPosition(double xPosition)
GameObjectsetXPosition in interface GameObjectxPosition - the position on x-axispublic double getYPosition()
GameObjectgetYPosition in interface GameObjectpublic void setYPosition(double yPosition)
GameObjectsetYPosition in interface GameObjectyPosition - the position on y-axispublic java.awt.geom.Point2D.Double getPosition()
GameObjectgetPosition in interface GameObjectpublic void setPosition(java.awt.geom.Point2D.Double point)
GameObjectsetPosition in interface GameObjectpoint - the positionpublic double getXVelocity()
GameObjectgetXVelocity in interface GameObjectpublic void setXVelocity(double xVelocity)
GameObjectsetXVelocity in interface GameObjectxVelocity - the velocity on x-axispublic double getYVelocity()
GameObjectgetYVelocity in interface GameObjectpublic void setYVelocity(double yVelocity)
GameObjectsetYVelocity in interface GameObjectyVelocity - the velocity on y-axispublic double getXDirection()
GameObjectgetXDirection in interface GameObjectpublic void setXDirection(double xDirection)
GameObjectsetXDirection in interface GameObjectxDirection - the direction on x-axispublic double getYDirection()
GameObjectgetYDirection in interface GameObjectpublic void setYDirection(double yDirection)
GameObjectsetYDirection in interface GameObjectyDirection - the direction on y-axispublic void setDirection(java.awt.geom.Point2D location)
GameObjectsetDirection in interface GameObjectlocation - a point containing the directionpublic java.awt.geom.Point2D.Double getDirection()
GameObjectgetDirection in interface GameObjectpublic void setDirectionToward(java.awt.geom.Point2D location)
setDirectionToward in interface GameObjectlocation - a point containing the location of a point to set direction topublic double getWidth()
GameObjectgetWidth in interface GameObjectpublic double getHeight()
GameObjectgetHeight in interface GameObjectpublic double getXCenter()
GameObjectgetXCenter in interface GameObjectpublic double getYCenter()
GameObjectgetYCenter in interface GameObjectpublic java.awt.geom.Point2D.Double getCenter()
GameObjectgetCenter in interface GameObjectpublic void gotHit()
gotHit in interface GameObjectpublic boolean isDead()
isDead in interface GameObjectpublic void makeDead()
makeDead in interface GameObjectpublic java.awt.image.BufferedImage getImage()
GameObjectgetImage in interface GameObjectpublic void setImage(java.awt.image.BufferedImage image)
GameObjectsetImage in interface GameObjectimage - the BufferedImage to be set as spritepublic void setImageLocation(java.lang.String imageLocation)
GameObjectsetImageLocation in interface GameObjectimageLocation - the path to the imagepublic int getHealthPoints()
GameObjectgetHealthPoints in interface GameObjectpublic void setHealthPoints(int helathPoints)
GameObjectsetHealthPoints in interface GameObjecthelathPoints - the number to set the HP as