games.pong.items
Class Powerup

java.lang.Object
  extended by vooga.gameEngine.game.GameRelatedObject
      extended by vooga.gameEngine.item.GameItem
          extended by vooga.physicsEngine.PhysicalItem
              extended by games.pong.items.PongItem
                  extended by games.pong.items.Powerup
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Renderable>, Collidable<Ball>, Renderable, Tangible
Direct Known Subclasses:
ReducePaddlePowerup

public abstract class Powerup
extends PongItem
implements Collidable<Ball>

A Powerup is an abstract class that will represent all Powerups in the game. Each Powerup will have an effect which is applied to the Paddle which hit the ball towards the Powerup. A Powerup needs knowledge of the other items in the game to affect their properties.

Author:
Ben Getson
See Also:
Serialized Form

Field Summary
 
Fields inherited from class vooga.physicsEngine.PhysicalItem
parameters
 
Constructor Summary
Powerup(java.lang.String url, double dimension, Pong game)
          Create a new Powerup with the given image and dimensions.
 
Method Summary
abstract  void applyEffect()
          Determines the effect of this Powerup.
 void collide(Ball otherObject)
          Apply the given effect for this Powerup, and then remove it from the game.
 Paddle getHittingPaddle()
           
 Paddle getOpponentPaddle()
           
 
Methods inherited from class games.pong.items.PongItem
changeImage, reduceSize, resetSize
 
Methods inherited from class vooga.physicsEngine.PhysicalItem
applyAngularImpulse, applyImpulse, getPhysicsOn, setConstantForce, setPhysicsOn, setPosition, setPosition
 
Methods inherited from class vooga.gameEngine.item.GameItem
compareTo, getPosition, getRotation, getShape, getSize, getTexture, isVisible, move, resize, rotate, setPosition, setRotation, setSize, setVisibility
 
Methods inherited from class vooga.gameEngine.game.GameRelatedObject
addEventListener, clearListeners, equals, fire, fire, fire, getEventListeners, getID, getListenerCount, removeEventListener
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface vooga.gameEngine.item.Renderable
getTexture, isVisible, setVisibility
 
Methods inherited from interface java.lang.Comparable
compareTo
 
Methods inherited from interface vooga.gameEngine.item.Tangible
getPosition, getRotation, getShape, getSize, move, resize, rotate, setPosition, setRotation, setSize
 

Constructor Detail

Powerup

public Powerup(java.lang.String url,
               double dimension,
               Pong game)
Create a new Powerup with the given image and dimensions.

Parameters:
url - the url of the image to assign to the Powerup
dimension - the dimension of each side of the Poweup. Assumes the Powerup will be a square
game - a reference to the Pong game. Needed to apply effects to each game object
Method Detail

applyEffect

public abstract void applyEffect()
Determines the effect of this Powerup. This will be implemented by each instance of a Powerup. The effect is not limited to the Paddle which activated the Powerup. It could be the opposing Paddle or the Ball.


collide

public void collide(Ball otherObject)
Apply the given effect for this Powerup, and then remove it from the game.

Specified by:
collide in interface Collidable<Ball>
Parameters:
otherObject - that has collided with this object

getHittingPaddle

public Paddle getHittingPaddle()
Returns:
the Paddle which hit the Ball towards the Powerup

getOpponentPaddle

public Paddle getOpponentPaddle()
Returns:
the Paddle which did not hit the Ball towards the Powerup