games.pong.items
Class Paddle
java.lang.Object
vooga.gameEngine.game.GameRelatedObject
vooga.gameEngine.item.GameItem
vooga.physicsEngine.PhysicalItem
games.pong.items.PongItem
games.pong.items.Paddle
- All Implemented Interfaces:
- MoveListener, java.io.Serializable, java.lang.Comparable<Renderable>, java.util.EventListener, Collidable<PhysicalItem>, Renderable, Tangible
public class Paddle
- extends PongItem
- implements MoveListener, Collidable<PhysicalItem>
The Paddle that a user will have to move around in defense of the goal.
It extends PhysicalItem and uses it's methods. Check GameItem JavaDoc for
details on its methods.
- Author:
- Lucas Best
- See Also:
- Serialized Form
Constructor Summary |
Paddle(double width,
double height)
Create a new Paddle as a Rectangle, and set it as immovable (so that it does
not recoil when the Ball bounces off it. |
Method Summary |
void |
collide(PhysicalItem otherObject)
This method is called whenever an object of the specified type has
collided with this object. |
void |
isHuman(boolean isHuman)
Set whether this paddle is controlled by a human |
void |
moveDown(MoveDownEvent e)
Move the source Paddle down |
void |
moveUp(MoveUpEvent e)
Move the source Paddle up |
void |
resetSize()
If the paddle is controlled by a computer, reset its size to normal. |
void |
setDelta(double delta)
Set the delta for this paddle. |
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 java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.lang.Comparable |
compareTo |
Paddle
public Paddle(double width,
double height)
- Create a new Paddle as a Rectangle, and set it as immovable (so that it does
not recoil when the Ball bounces off it.
moveUp
public void moveUp(MoveUpEvent e)
- Description copied from interface:
MoveListener
- Move the source Paddle up
- Specified by:
moveUp
in interface MoveListener
- Parameters:
e
- a reference to the Event
moveDown
public void moveDown(MoveDownEvent e)
- Description copied from interface:
MoveListener
- Move the source Paddle down
- Specified by:
moveDown
in interface MoveListener
- Parameters:
e
- a reference to the Event
setDelta
public void setDelta(double delta)
- Set the delta for this paddle. Used when applying the AI to a paddle.
- Parameters:
delta
-
isHuman
public void isHuman(boolean isHuman)
- Set whether this paddle is controlled by a human
- Parameters:
isHuman
- controlled by a human or computer
resetSize
public void resetSize()
- If the paddle is controlled by a computer, reset its size to normal.
Leave human players reduced between levels.
- Overrides:
resetSize
in class PongItem
collide
public void collide(PhysicalItem otherObject)
- Description copied from interface:
Collidable
- This method is called whenever an object of the specified type has
collided with this object.
- Specified by:
collide
in interface Collidable<PhysicalItem>
- Parameters:
otherObject
- that has collided with this object