data
Class Player

java.lang.Object
  extended by data.GameEntity
      extended by data.Player

public class Player
extends GameEntity

Author:

Field Summary
private  boolean chainSting
           
private  long frameDuration
          Frame duration in milliseconds since GameEngine works in terms of milliseconds
private  int frameNumber
          The current frame
private  Sprite[] framesLeft
          Animation frames
private  Sprite[] framesRight
          Animation frames
private  long invincibility
          If player take a shield bonus, s/he will be invincible to the balloon collisions.
private  boolean invincible
          These variables are in boolean format and they represent and activate the bonuses that player takes during gameplay.
private  long lastFrameChange
          Time from the last frame change
private  boolean left
          If player is supposed to go to left.
private  int lives
          Number of lives of a player.
private  boolean multipleStings
           
private  boolean resurrect
          If player entered a resurrection state, which is when player got shot by a balloon and still has lives before game over.
private  long resurrection
          Resurrection state time.
private  boolean right
          If player is supposed to go to right.
private  int score
          Score of the player.
private  Sprite shield
          To draw the shield bonus when taken, it is created here.
private  int stingSize
          How many sting one player has shot.
private  boolean timeStop
           
 
Fields inherited from class data.GameEntity
dx, dy, ge, sm, sprite, x, y
 
Constructor Summary
Player(GameEngine ge, java.lang.String file, int x, int y, ScreenManager sm, java.lang.String playerFolder)
          Player Entity object is created.
 
Method Summary
 void addLives(int x)
          When player gets a life bonus his/her life will be increased.
 void addScore(int x)
          Adds score to player.
 void collidedWith(GameEntity entity)
          When player collides with a Balloon s/he enters a respawn state unless s/he has 0 lives.
 void draw(java.awt.Graphics2D g)
          If player has the shield bonus, this method will also draw a shield around player.
 void fire()
          Player attemts to shoot a Sting
 int getLives()
          Number of lives of player.
 int getScore()
           
 void initialize()
           
 boolean isChainSting()
           
 boolean isInvincible()
           
 boolean isMultipleStings()
           
 boolean isResurrect()
           
 boolean isTimeStop()
           
 void move(long delta)
          This method is heavily overriden as animation frames are also changing when player moves.
 long resurrection()
           
 void setChainSting(boolean chainSting)
           
 void setInvincible(boolean invincible)
           
 void setLeft(boolean left)
           
 void setMultipleStings(boolean multipleStings)
           
 void setResurrect(boolean resurrect)
           
 void setRight(boolean right)
           
 void setTimeStop(boolean timeStop)
           
 void setX(int x)
           
 void stingVanished()
           
 
Methods inherited from class data.GameEntity
collidesWith, getX, getY
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

framesRight

private Sprite[] framesRight
Animation frames


framesLeft

private Sprite[] framesLeft
Animation frames


lastFrameChange

private long lastFrameChange
Time from the last frame change


frameDuration

private long frameDuration
Frame duration in milliseconds since GameEngine works in terms of milliseconds


frameNumber

private int frameNumber
The current frame


shield

private Sprite shield
To draw the shield bonus when taken, it is created here.


right

private boolean right
If player is supposed to go to right.


left

private boolean left
If player is supposed to go to left.


stingSize

private int stingSize
How many sting one player has shot.


lives

private int lives
Number of lives of a player. It is 3 by default.


score

private int score
Score of the player. It is 0 by default.


resurrect

private boolean resurrect
If player entered a resurrection state, which is when player got shot by a balloon and still has lives before game over.


resurrection

private long resurrection
Resurrection state time.


invincibility

private long invincibility
If player take a shield bonus, s/he will be invincible to the balloon collisions.


invincible

private boolean invincible
These variables are in boolean format and they represent and activate the bonuses that player takes during gameplay.


timeStop

private boolean timeStop

multipleStings

private boolean multipleStings

chainSting

private boolean chainSting
Constructor Detail

Player

public Player(GameEngine ge,
              java.lang.String file,
              int x,
              int y,
              ScreenManager sm,
              java.lang.String playerFolder)
Player Entity object is created.

Parameters:
ge -
file -
x -
y -
sm -
playerFolder -
Method Detail

move

public void move(long delta)
This method is heavily overriden as animation frames are also changing when player moves.

Overrides:
move in class GameEntity
Parameters:
delta - is the amount of time that entity will move.

fire

public void fire()
Player attemts to shoot a Sting


collidedWith

public void collidedWith(GameEntity entity)
When player collides with a Balloon s/he enters a respawn state unless s/he has 0 lives.

Specified by:
collidedWith in class GameEntity

draw

public void draw(java.awt.Graphics2D g)
If player has the shield bonus, this method will also draw a shield around player.

Overrides:
draw in class GameEntity
Parameters:
g - A Graphics2D object coming from GameEngine

getLives

public int getLives()
Number of lives of player.

Returns:

addLives

public void addLives(int x)
When player gets a life bonus his/her life will be increased. This method also used when collision with balloon occurs to decrease the life with parameter -1

Parameters:
x - to set the life player will receiver.

addScore

public void addScore(int x)
Adds score to player.

Parameters:
x - quantity of score.

isInvincible

public boolean isInvincible()
Returns:
If player has the shield bonus, thus invincible.

isTimeStop

public boolean isTimeStop()
Returns:
If player has freezer bonus.

isMultipleStings

public boolean isMultipleStings()
Returns:
If player can shoot two stings at a time.

isChainSting

public boolean isChainSting()
Returns:
If player is able to shoot chains.

setInvincible

public void setInvincible(boolean invincible)

setTimeStop

public void setTimeStop(boolean timeStop)

setMultipleStings

public void setMultipleStings(boolean multipleStings)

setChainSting

public void setChainSting(boolean chainSting)

getScore

public int getScore()

setX

public void setX(int x)

setRight

public void setRight(boolean right)

setLeft

public void setLeft(boolean left)

stingVanished

public void stingVanished()

initialize

public void initialize()

isResurrect

public boolean isResurrect()

setResurrect

public void setResurrect(boolean resurrect)

resurrection

public long resurrection()