org.vizzini.example.pong
Class Ball

java.lang.Object
  extended by org.vizzini.game.AbstractToken
      extended by org.vizzini.example.pong.Ball
All Implemented Interfaces:
Serializable, Cloneable, IToken

public class Ball
extends AbstractToken

Provides a ball for Pong.

Since:
v0.1
Version:
v0.3
Author:
Jeffrey M. Thompson
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.vizzini.game.AbstractToken
UNKNOWN_NAME
 
Fields inherited from interface org.vizzini.game.IToken
AGENT_PROPERTY, NAME_PROPERTY, POSITION_PROPERTY, TEAM_PROPERTY
 
Constructor Summary
Ball()
          Construct this object.
 
Method Summary
 void configure(Properties properties, int index)
          Configure this token.
 Rectangle getBounds()
          Return the bounds.
 int getRadius()
          Return the radius.
 int getSpeed()
          Return the speed.
 VectorPosition getVelocity()
          Return the velocity.
 boolean isBounced()
          Return true if this has bounced.
protected  boolean isBounced(Paddle paddle)
          Return true if the ball should bounce off the given paddle.
protected  boolean isBounced(Rectangle obstacle)
          Return true if the ball should bounce.
 void setAcceleration(double acceleration)
          Set the scalar acceleration.
 void setRadius(int radius)
          Set the radius.
 void setSpeed(int speed)
          Set the speed.
 void setVelocity(VectorPosition velocity)
          Set the velocity.
 void updatePosition(Rectangle top, Rectangle bottom, Paddle leftPaddle, Paddle rightPaddle)
          Update the position.
 
Methods inherited from class org.vizzini.game.AbstractToken
addPropertyChangeListener, clone, copy, equals, getAgent, getIndex, getName, getPosition, getPropertyChangeManager, getTeam, getValue, hashCode, isFiringPositionChanges, removePropertyChangeListener, setAgent, setFiringPositionChanges, setIndex, setName, setPosition, setTeam, setValue, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Ball

public Ball()
Construct this object.

Since:
v0.2
Method Detail

configure

public void configure(Properties properties,
                      int index)
Configure this token.

Specified by:
configure in interface IToken
Overrides:
configure in class AbstractToken
Parameters:
properties - Source of configuration information.
index - Index of this token's properties.
Since:
v0.1

getBounds

public Rectangle getBounds()
Return the bounds.

Since:
v0.1

getRadius

public int getRadius()
Return the radius.

Since:
v0.1

getSpeed

public int getSpeed()
Return the speed.

Since:
v0.1

getVelocity

public VectorPosition getVelocity()
Return the velocity.

Since:
v0.1

isBounced

public boolean isBounced()
Return true if this has bounced.

Since:
v0.1

setAcceleration

public void setAcceleration(double acceleration)
Set the scalar acceleration.

Since:
v0.1

setRadius

public void setRadius(int radius)
Set the radius.

Since:
v0.1

setSpeed

public void setSpeed(int speed)
Set the speed.

Since:
v0.1

setVelocity

public void setVelocity(VectorPosition velocity)
Set the velocity.

Since:
v0.1

updatePosition

public void updatePosition(Rectangle top,
                           Rectangle bottom,
                           Paddle leftPaddle,
                           Paddle rightPaddle)
Update the position.

Since:
v0.1

isBounced

protected boolean isBounced(Rectangle obstacle)
Return true if the ball should bounce.

Since:
v0.1

isBounced

protected boolean isBounced(Paddle paddle)
Return true if the ball should bounce off the given paddle.

Since:
v0.1


Copyright © 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02