Ball Class Reference

Representation of the player of the Pong game. More...

List of all members.

Public Member Functions


Detailed Description

This class stores the position and velocty of the ball, updates and draws it.


Constructor & Destructor Documentation

Ball::Ball ( vec3  pos = vec3(),
vec3  vel = vec3() 
)

Constructor.

Constructor that sets the ball's position and velocity to the given values.

Parameters:
pos The ball's initial position. Defaults to (0, 0).
vel The ball's initial velocity. Defaults to (0, 0).
See also:
~Ball(float, float, float, float), ~Ball()
Ball::Ball ( float  x,
float  y,
float  velX = 0,
float  velY = 0 
)

Constructor.

Constructor that sets the ball's position and velocity to the given values.

Parameters:
x The ball's initial x-coordinate.
y The ball's initial y-coordinate.
velX The x-coordinate of the ball's initial velocity. Defaults to 0.
velY The y-coordinate of the ball's initial velocity. Defaults to 0.
See also:
~Ball(vec3, vec3), ~Ball()
Ball::~Ball ( void   ) 

Default destructor.

See also:
Ball(vec3, vec3), Ball(float, float, float, float)

Member Function Documentation

float Ball::x (  ) 

Returns the ball's current x-coordinate.

Returns:
The ball's current x-coordinate.
See also:
y(), pos(), setPos(vec3), setPos(float, float)
float Ball::y (  ) 

Returns the ball's current y-coordinate.

Returns:
The ball's current y-coordinate.
See also:
x(), pos(), setPos(vec3), setPos(float, float)
void Ball::setPos ( vec3  pos  ) 

Sets the ball's current position.

Parameters:
pos The ball's new position.
See also:
setPos(float, float), pos(), x(), y()
void Ball::setPos ( float  x,
float  y 
)

Sets the ball's current position.

Parameters:
x The ball's new x-coordinate.
y The ball's new y-coordinate.
See also:
setPos(float, float), pos(), x(), y()
void Ball::setVel ( vec3  vel = vec3()  ) 

Sets the ball's current velocity.

Parameters:
vel The ball's new velocity. Defaults to (0, 0).
void Ball::update (  ) 

Updates the ball's current position using only its own velocity.

Calls proposeMove() to simply move one step ahead according to the ball's current velocity.

See also:
proposeMove(), update(vec3, vec3, PongMode)
void Ball::update ( vec3  vel,
vec3  playerPos,
PongMode  mode 
)

Updates the ball's current position and velocity using external forces.

First updates the ball's current velocity by taking an average of it's own velocity and the velocity of the flow data at its position. Then, if the player is currently in attraction or repulsion mode, the ball's velocity is further adjusted using an appropriate attraction or repulsion force, inversely strong to the distance between ball and player. Finally calls proposeMove() to move one step ahead according to the ball's updated velocity.

See also:
proposeMove(), update()

Generated on Thu Jan 21 00:31:55 2010 for simpleVIS by  doxygen 1.6.1