client.brickblock.objects
Class Powerup

java.lang.Object
  extended by Sprite
      extended by client.brickblock.objects.Powerup
Direct Known Subclasses:
SizeUp, SpeedUp, StrengthUp

public abstract class Powerup
extends Sprite

Abstract class used for power up objects. All power up objects have an increment value that determines the effect of the power up, and can be activated and deactivated. This class extends the Sprite, and power up objects can therefore be placed directly on the game board (by the LayerManager.

Author:
Martin Jarrett, Eivind Sorteberg

Field Summary
protected  int increment
          The value with which the player's affected value is incremented
 
Constructor Summary
protected Powerup(java.lang.String imageAddress, int xPos, int yPos, int increment)
          Constructor that assigns an image to the power up object, as well as defining a position and duration.
 
Method Summary
abstract  void activate(BBPlayer player)
          "Turns on" the power up by increasing one of the player's attributes.
static Powerup createPowerup(java.lang.String type, int xPos, int yPos, int value)
          Creates a power up object with the given attributes.
abstract  void deactivate(BBPlayer player)
          "Turns off" the power up by restoring the player's attribute to the value it would have had if the power up had not been picked up.
abstract  java.lang.String getPowerUpName()
          Returns a three letter String representation of the power up object.
 java.lang.Object[] getValues()
          Returns the attributes of the power up object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

increment

protected int increment
The value with which the player's affected value is incremented

Constructor Detail

Powerup

protected Powerup(java.lang.String imageAddress,
                  int xPos,
                  int yPos,
                  int increment)
           throws java.io.IOException
Constructor that assigns an image to the power up object, as well as defining a position and duration.

Parameters:
imageAddress - The location of the image to use.
xPos - The object's x-position on the screen.
yPos - The object's y-position on the screen.
increment - The increment of the power up.
Throws:
java.io.IOException - If the image file is not found.
Method Detail

activate

public abstract void activate(BBPlayer player)
"Turns on" the power up by increasing one of the player's attributes. How this power up affects the player is dependent on how this method is implemented.

Parameters:
player - The player that is affected by the power up.

deactivate

public abstract void deactivate(BBPlayer player)
"Turns off" the power up by restoring the player's attribute to the value it would have had if the power up had not been picked up.

Parameters:
player - The player that is affected by the power up.

getPowerUpName

public abstract java.lang.String getPowerUpName()
Returns a three letter String representation of the power up object.

Returns:
The name of the power up object

createPowerup

public static Powerup createPowerup(java.lang.String type,
                                    int xPos,
                                    int yPos,
                                    int value)
Creates a power up object with the given attributes. The type of power up object is specified by the three letter name specified in the type attribute. When new implentors of this class is created, the list of types in this method needs to be updated.

Parameters:
type - The type of power up to create.
xPos - The horizontal position of the object.
yPos - The vertical position of the object.
value - The increment value of the object.
Returns:
A power up object with the specified attributes.

getValues

public java.lang.Object[] getValues()
Returns the attributes of the power up object. Is used to provide a parser with object values.

Returns:
An array containing the object's attributes.