se.liu.student.kimgr905.tilegame.sprites
Class Player

java.lang.Object
  extended by se.liu.student.kimgr905.tilegame.sprites.Sprite
      extended by se.liu.student.kimgr905.tilegame.sprites.Ship
          extended by se.liu.student.kimgr905.tilegame.sprites.Player

public final class Player
extends Ship

The Player


Field Summary
private  int ammo
           
private static int AMMO_DOUBLE
           
private  int currentWeapon
           
static float DOBULE_X1
          Left double lazer x-position.
static float DOBULE_X2
          Right double lazer x-position.
static int DOUBLE_LAZER
          Double lazer.
static float DOUBLE_Y
          Double lazer y-position.
private static int HIT_POINTS
           
private static int KNOCKBACK
           
private static float MAX_SPEED
           
private static int SHIELD_POINTS
           
private  int shieldPoints
           
static int SINGLE_LAZER
          Single lazer.
static float SINGLE_X
          Single lazer x-position.
static float SINGLE_Y
          Single lazer y-position.
 
Fields inherited from class se.liu.student.kimgr905.tilegame.sprites.Sprite
anim, STATE_DEAD, STATE_EXPLODING, STATE_NORMAL, STATE_SHOOTING
 
Constructor Summary
Player(Animation normal, Animation exploding)
          Creates a player ship with the specified animations.
 
Method Summary
 int getAmmo()
          Returns the ammo of DOUBLE_LAZER.
 int getMaxAmmo()
          Returns max ammo of DOUBLE_LAZER.
 int getMaxHitPoints()
          Returns the maximum hitpoints of the player.
 float getMaxSpeed()
          Returns the max speed of the player.
 int getShieldPoints()
          Returns the current shield points.
 int getWeapon()
          Gets the current weapon, it can either be SINGLE_LAZER or DOUBLE_LAZER.
 void hit()
          When the player gets hit by an enemy or enemyshot, if he has shieldpoints that will be reduced otherwise he loses hitpoints.
 int playerKnockbackHorizontal(Sprite collisionSprite)
          Returns how much the player gets knocked back at a collision, on the x-axis.
 int playerKnockbackVertical(Sprite collisionSprite)
          Returns how much the player gets knocked back at a collision, on the y-axis.
 void setShield()
          Enable the shield for the player, setting the variable shieldPoints to SHIELD_POINTS
private  void setShieldPoints(int shieldPoints)
           
 void setWeapon(int newWeapon)
          Sets a new weapon for the player.
 void shoot()
          Decreases ammo, sets back to standard weapon when the player is out of ammo and also signals that the player is done shooting.
 
Methods inherited from class se.liu.student.kimgr905.tilegame.sprites.Ship
changePath, changePath, clone, getHitPoints, isAwake, setHitPoints, setState, update, wakeUp
 
Methods inherited from class se.liu.student.kimgr905.tilegame.sprites.Sprite
getHeight, getImage, getState, getVelocityX, getVelocityY, getWidth, getX, getY, isAlive, setVelocityX, setVelocityY, setX, setY
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HIT_POINTS

private static final int HIT_POINTS
See Also:
Constant Field Values

SHIELD_POINTS

private static final int SHIELD_POINTS
See Also:
Constant Field Values

MAX_SPEED

private static final float MAX_SPEED
See Also:
Constant Field Values

KNOCKBACK

private static final int KNOCKBACK
See Also:
Constant Field Values

SINGLE_LAZER

public static final int SINGLE_LAZER
Single lazer.

See Also:
Constant Field Values

DOUBLE_LAZER

public static final int DOUBLE_LAZER
Double lazer.

See Also:
Constant Field Values

AMMO_DOUBLE

private static final int AMMO_DOUBLE
See Also:
Constant Field Values

SINGLE_X

public static final float SINGLE_X
Single lazer x-position.

See Also:
Constant Field Values

SINGLE_Y

public static final float SINGLE_Y
Single lazer y-position.

See Also:
Constant Field Values

DOBULE_X1

public static final float DOBULE_X1
Left double lazer x-position.

See Also:
Constant Field Values

DOBULE_X2

public static final float DOBULE_X2
Right double lazer x-position.

See Also:
Constant Field Values

DOUBLE_Y

public static final float DOUBLE_Y
Double lazer y-position.

See Also:
Constant Field Values

shieldPoints

private int shieldPoints

currentWeapon

private int currentWeapon

ammo

private int ammo
Constructor Detail

Player

public Player(Animation normal,
              Animation exploding)
Creates a player ship with the specified animations.

Parameters:
normal - normal animation
exploding - exploding animation
Method Detail

getMaxSpeed

public float getMaxSpeed()
Returns the max speed of the player.

Returns:
MAX_SPEED

getMaxHitPoints

public int getMaxHitPoints()
Returns the maximum hitpoints of the player.

Returns:
HIT_POINTS

getShieldPoints

public int getShieldPoints()
Returns the current shield points.

Returns:
current shieldPoints

setShieldPoints

private void setShieldPoints(int shieldPoints)

setShield

public void setShield()
Enable the shield for the player, setting the variable shieldPoints to SHIELD_POINTS


getAmmo

public int getAmmo()
Returns the ammo of DOUBLE_LAZER.

Returns:
ammo

getMaxAmmo

public int getMaxAmmo()
Returns max ammo of DOUBLE_LAZER.

Returns:
AMMO_DOUBLE

hit

public void hit()
When the player gets hit by an enemy or enemyshot, if he has shieldpoints that will be reduced otherwise he loses hitpoints. When his hitpoints reaches 0 the player dies.

Overrides:
hit in class Ship

setWeapon

public void setWeapon(int newWeapon)
Sets a new weapon for the player. Also gives that weapon ammunition.

Parameters:
newWeapon - a new weapon for the player

getWeapon

public int getWeapon()
Gets the current weapon, it can either be SINGLE_LAZER or DOUBLE_LAZER.

Returns:
currentWeapon

shoot

public void shoot()
Decreases ammo, sets back to standard weapon when the player is out of ammo and also signals that the player is done shooting.

Overrides:
shoot in class Ship

playerKnockbackVertical

public int playerKnockbackVertical(Sprite collisionSprite)
Returns how much the player gets knocked back at a collision, on the y-axis.

Parameters:
collisionSprite - colliding sprite
Returns:
knockbackvalue

playerKnockbackHorizontal

public int playerKnockbackHorizontal(Sprite collisionSprite)
Returns how much the player gets knocked back at a collision, on the x-axis.

Parameters:
collisionSprite - colliding sprite
Returns:
knockbackvalue