server.brickblock.objects
Class Powerup

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

public abstract class Powerup
extends java.lang.Object

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.

Author:
Martin Jarrett, Eivind Sorteberg

Field Summary
static int DEFAULT_DURATION_SECS
           
static int DEFAULT_SIZE
           
 
Constructor Summary
protected Powerup(int xPos, int yPos, int duration)
          Constructor that assigns a position to the power up object, as well as defining the duration.
 
Method Summary
abstract  void activate(BBPlayer player)
          "Turns on" the power up by increasing one of the player's 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.Object getAffectedAttribute(BBPlayer player)
          Returns the player attribute that is affected by the power up object, i.e. speed, size, or strength.
 java.lang.String[] getAttributes()
          Returns the power up's attribues, i.e. the power up's type, position, and increment value.
 int getDuration()
          Returns the duration of the power up.
abstract  int getIncrement()
          Returns the power up's increment value, i.e. how much the player's affected attribute is incremented when picking up the power up.
abstract  java.lang.String getName()
          Returns a three letter String representation of the power up object.
 int[] getPosition()
           
 long getTimeout()
           
 void setDuration(int duration)
          Sets the duration of the power up to the specified value.
 void setPosition(int xPos, int yPos)
          Sets the position of the power up.
 void setTimeout(long timeout)
          Sets the time for when this power up will no longer remain active for the player that has picked it up.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SIZE

public static final int DEFAULT_SIZE
See Also:
Constant Field Values

DEFAULT_DURATION_SECS

public static final int DEFAULT_DURATION_SECS
See Also:
Constant Field Values
Constructor Detail

Powerup

protected Powerup(int xPos,
                  int yPos,
                  int duration)
Constructor that assigns a position to the power up object, as well as defining the duration.

Parameters:
xPos - The object's x-position on the screen.
yPos - The object's y-position on the screen.
duration - How long the power up remains active.
Method Detail

setPosition

public void setPosition(int xPos,
                        int yPos)
Sets the position of the power up.

Parameters:
xPos - The object's x-position.
yPos - The object's y-position.

getPosition

public int[] getPosition()
Returns:
The object's position.

getDuration

public int getDuration()
Returns the duration of the power up. This is how long the power up remains active after it has been picked up, and is not affected by how long it has been on the table before it is picked up.

Returns:
The power up's duration.

setDuration

public void setDuration(int duration)
Sets the duration of the power up to the specified value. This is how long the power up remains active after it has been picked up, and is not affected by how long it has been on the table before it is picked up.

Parameters:
duration - The power up's duration.

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.

getAffectedAttribute

public abstract java.lang.Object getAffectedAttribute(BBPlayer player)
Returns the player attribute that is affected by the power up object, i.e. speed, size, or strength.

Parameters:
player - A BBPlayer object.
Returns:
The affected attribute.

getAttributes

public java.lang.String[] getAttributes()
Returns the power up's attribues, i.e. the power up's type, position, and increment value.

Returns:
The power up's attributes.

getName

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

Returns:
The name of the power up object

setTimeout

public void setTimeout(long timeout)
Sets the time for when this power up will no longer remain active for the player that has picked it up.

Parameters:
timeout - When the power up is deactivated.

getTimeout

public long getTimeout()
Returns:
When the power up is deactivated.

getIncrement

public abstract int getIncrement()
Returns the power up's increment value, i.e. how much the player's affected attribute is incremented when picking up the power up.

Returns:
The power up's increment value.