BubbleField Class Reference

"Glued-on" bubbles in the play field. More...

#include <bubble_field.h>

Inheritance diagram for BubbleField:

TimeUpdateable GraphicalNode Templates::CallableBack< Bubble >

List of all members.

Public Member Functions

 BubbleField ()
 Default constructor.
 ~BubbleField ()
 Destructor.
void setOnSuccessfullGameEndCallback (void(*callback)())
 Set callback that should be called on successfull game end.
void generateStartingLayout (const BubbleGenerator *bubbleGen, unsigned numOfInitiallyFilledPlates, float probCellContainBubble)
 Generates starting layout.
void addBubble (Bubble *bubble, Templates::CallableBack< BubbleField > *addBubbleDone)
 Adds bubble to the field.
bool isInCollision (const SbVec3f &position)
 Check for a collision.
virtual void timeUpdate (float dt)
 Timer value change event occured.
virtual void callableBackNotify (Bubble *subject)
 Subject performed action on which the callback was defined.

Static Public Member Functions

static unsigned getNumberOfBubblesInRow ()
 Returns the number of bubbles in one row.

Private Types

typedef Bubble *** BubblePlate
 Types used in for the field content.
typedef std::vector< BubblePlateFieldContent

Private Member Functions

 BubbleField (const BubbleField &)
BubbleFieldoperator= (const BubbleField &)
unsigned bubblesInPlateRow (unsigned index) const
 Returns number of Bubbles in one row (or column) in given plate.
bool isValidPosition (unsigned plate, unsigned x, unsigned y) const
 Returns true if given coordinates are valid in the Bubble Field.
bool bubbleCollidesInPlate (unsigned plate, const SbVec3f &position) const
 Returns true if bubble collides in given plate.
void addCollidingBubblesInPlateToVector (unsigned plate, const Bubble *bubble, std::vector< const Bubble * > &collidingBubbles) const
 Adds bubbles colliding to given bubble to given vector.
void solveCollisionWithWall (Bubble *bubble)
 Solves collision of the given bubble with the wall.
void solveCollisionWithBubble (Bubble *bubble)
 Solves collision of the given bubble with the wall.
void destroyBubblesInCluster (const Coordinates &position)
 Remove bubbles of the same type in one cluster.
void removeBubblesNotConnectedWithWall ()
 Selects bubbles not connected with the rear wall and removes them.
Coordinates searchForPosition (Bubble *bubble) const
 Searches for nearest suitable position for given bubble.
std::vector< const Bubble * > getCollidingBubbles (Bubble *bubble) const
 Returns vector of bubbles that are in collision with given bubble.
std::list< CoordinatesgetNeighboursCoords (const Coordinates &coords) const
 Returns list of Coordinates that are neighbours' positions.
void addBubble (Bubble *bubble, unsigned plate, unsigned x, unsigned y)
 Adds the selected bubble to the selected location.
void addNeighboursTowardsWall (const BubbleGenerator *bubbleGen, const Coordinates &coords)
 Recursively adds neighbours towards the rear wall until the wall is hit.
bool isConnectedWithWall (const Coordinates &coords, std::vector< Coordinates > processedCoords, Coordinates &nearestToWallCoords) const
 Returns true if the bubble at the selected coordinates is connected to the rear wall, false otherwise.
bool isConnectedWithWall (const Coordinates &coords) const
 Returns true if the bubble at the selected coordinates is connected to the rear wall, false otherwise. Wrapper around isConnectedWithWall(const Coordinates&, std::vector<Coordinates>, Coordinates&) const.

Static Private Member Functions

static bool isInCollisionWithWall (const SbVec3f &position)
 Returns true if the bubble is in collision with the rear wall.
static unsigned oiXYCoordinateToLocal (float oiCoord, unsigned plate, float(*roundFunc)(float)=roundf)
 Transforms selected OI coordinate (X or Y) into a local coordinate.
static unsigned oiZCoordinateToLocal (float oiCoord, float(*roundFunc)(float)=roundf)
 Transforms z-axis OI coordinate into a local coordinate.
static SbVec3f localCoordinatesToOI (unsigned plate, unsigned x, unsigned y)
 Transforms local coordinates to these in OI.
static SbVec3f localCoordinatesToOI (Coordinates local)
 Transforms local coordinates to these in OI.

Private Attributes

FieldContent _content
 Content of the field.
Templates::CallableBack
< BubbleField > * 
_addBubbleDone
std::list< Bubble * > _explodingBubbles
 Container to store bubbles that are exploding at the moment.
int _explodingBubblesCount
 Stores the number of bubbles that are exploding at the moment.
FallingBubblesStorage _fallingBubbles
 Stores falling bubbles because they are not connected to the rear wall.
void(* _successGameEndFunc )()
 Function that should be called on successfull game end.

Static Private Attributes

static const unsigned BUBBLES_IN_ROW
 Number of bubbles in one row.

Classes

class  Coordinates
 Class that encapsulates coordinates used in BubbleField. More...
class  FallingBubblesStorage
 Stores Bubbles that are going to be removed because they were not connected with rear wall. More...
class  isInvalidPosition
 Functor that returns true if given position is outside BubbleField area. More...


Detailed Description

"Glued-on" bubbles in the play field.

This class represents "glued-on" bubbles on the rear wall of the play field.

Reference object (cannot be copied).


Member Typedef Documentation

typedef Bubble*** BubbleField::BubblePlate [private]

Types used in for the field content.

typedef std::vector<BubblePlate> BubbleField::FieldContent [private]


Constructor & Destructor Documentation

BubbleField::BubbleField ( const BubbleField  )  [private]

BubbleField::BubbleField (  ) 

Default constructor.

BubbleField::~BubbleField (  ) 

Destructor.


Member Function Documentation

BubbleField& BubbleField::operator= ( const BubbleField  )  [private]

unsigned BubbleField::bubblesInPlateRow ( unsigned  index  )  const [private]

Returns number of Bubbles in one row (or column) in given plate.

Parameters:
[in] index Plate index

bool BubbleField::isValidPosition ( unsigned  plate,
unsigned  x,
unsigned  y 
) const [private]

Returns true if given coordinates are valid in the Bubble Field.

Parameters:
[in] plate Plate index
[in] x X-axis coordinate
[in] y Y-axis coordinate

Referenced by BubbleField::isInvalidPosition::operator()().

static bool BubbleField::isInCollisionWithWall ( const SbVec3f &  position  )  [static, private]

Returns true if the bubble is in collision with the rear wall.

Parameters:
[in] position Vector representing position of the bubble

bool BubbleField::bubbleCollidesInPlate ( unsigned  plate,
const SbVec3f &  position 
) const [private]

Returns true if bubble collides in given plate.

Parameters:
[in] plate Index of the plate to be checked
[in] position Vector representing position of the bubble

void BubbleField::addCollidingBubblesInPlateToVector ( unsigned  plate,
const Bubble bubble,
std::vector< const Bubble * > &  collidingBubbles 
) const [private]

Adds bubbles colliding to given bubble to given vector.

Parameters:
[in] plate Index of the plate to be checked
[in] bubble Given bubble
[out] collidingBubbles Vector where the bubbles should be placed

void BubbleField::solveCollisionWithWall ( Bubble bubble  )  [private]

Solves collision of the given bubble with the wall.

Parameters:
[in] bubble Given bubble

void BubbleField::solveCollisionWithBubble ( Bubble bubble  )  [private]

Solves collision of the given bubble with the wall.

Parameters:
[in] bubble Given bubble

void BubbleField::destroyBubblesInCluster ( const Coordinates position  )  [private]

Remove bubbles of the same type in one cluster.

Parameters:
[in] position Position where was last bubble added

void BubbleField::removeBubblesNotConnectedWithWall (  )  [private]

Selects bubbles not connected with the rear wall and removes them.

Coordinates BubbleField::searchForPosition ( Bubble bubble  )  const [private]

Searches for nearest suitable position for given bubble.

Parameters:
[in] bubble Given bubble

std::vector<const Bubble*> BubbleField::getCollidingBubbles ( Bubble bubble  )  const [private]

Returns vector of bubbles that are in collision with given bubble.

Parameters:
[in] bubble Given bubble
Returns:
Returns vector of bubbles with which given bubble is in collision

std::list<Coordinates> BubbleField::getNeighboursCoords ( const Coordinates coords  )  const [private]

Returns list of Coordinates that are neighbours' positions.

Parameters:
[in] coords Coordinates of given position

void BubbleField::addBubble ( Bubble bubble,
unsigned  plate,
unsigned  x,
unsigned  y 
) [private]

Adds the selected bubble to the selected location.

Parameters:
[in] bubble Bubble ot be added
[in] plate Plate coordinate to the field
[in] x X coordinate to the field
[in] y Y coordinate to the field
Selected location have to be valid and there must not already be a bubble.

void BubbleField::addNeighboursTowardsWall ( const BubbleGenerator bubbleGen,
const Coordinates coords 
) [private]

Recursively adds neighbours towards the rear wall until the wall is hit.

Parameters:
[in] bubbleGen Bubble Generator
[in] coords Coordinates of a bubble for which this function adds neighbours towards wall

bool BubbleField::isConnectedWithWall ( const Coordinates coords,
std::vector< Coordinates processedCoords,
Coordinates nearestToWallCoords 
) const [private]

Returns true if the bubble at the selected coordinates is connected to the rear wall, false otherwise.

Parameters:
[in] coords Current bubble coordinates
[in] processedCoords Already checked coordinates (to prevent endless recursion)
[out] nearestToWallCoords Coordinates which are nearest to the wall

bool BubbleField::isConnectedWithWall ( const Coordinates coords  )  const [private]

Returns true if the bubble at the selected coordinates is connected to the rear wall, false otherwise. Wrapper around isConnectedWithWall(const Coordinates&, std::vector<Coordinates>, Coordinates&) const.

Parameters:
[in] coords Current bubble coordinates

static unsigned BubbleField::oiXYCoordinateToLocal ( float  oiCoord,
unsigned  plate,
float(*)(float)  roundFunc = roundf 
) [static, private]

Transforms selected OI coordinate (X or Y) into a local coordinate.

Parameters:
[in] oiCoord OI X (or Y) coordinate value
[in] plate Plate index
[in] roundFunc Rounding function (roundf, floor, ceil, ...)
Returns:
Local X (or Y) coordinate
X and Y coordinates have always the same value.

static unsigned BubbleField::oiZCoordinateToLocal ( float  oiCoord,
float(*)(float)  roundFunc = roundf 
) [static, private]

Transforms z-axis OI coordinate into a local coordinate.

Parameters:
[in] oiCoord Z coordinate value
[in] roundFunc Rounding function (roundf, floor, ceil, ...)
Returns:
Local X Z coordinate

static SbVec3f BubbleField::localCoordinatesToOI ( unsigned  plate,
unsigned  x,
unsigned  y 
) [static, private]

Transforms local coordinates to these in OI.

Parameters:
[in] plate Plate index
[in] x Local X coordinate
[in] y Local Y coordinate
Returns:
Coordinates in OI

static SbVec3f BubbleField::localCoordinatesToOI ( Coordinates  local  )  [static, private]

Transforms local coordinates to these in OI.

Parameters:
[in] local Local coordinates
Returns:
Coordinates in OI
Calls localCoordinatesToOI(unsigned plate, unsigned x, unsigned y)

void BubbleField::setOnSuccessfullGameEndCallback ( void(*)()  callback  ) 

Set callback that should be called on successfull game end.

Parameters:
callback Callback to be set.
This function should be called after the object is created (if it is not called, the game will continue even if the player should have won).

void BubbleField::generateStartingLayout ( const BubbleGenerator bubbleGen,
unsigned  numOfInitiallyFilledPlates,
float  probCellContainBubble 
)

Generates starting layout.

Parameters:
[in] bubbleGen Bubble Generator
[in] numOfInitiallyFilledPlates Number of initially filled plates with bubbles
[in] probCellContainBubble Probability that a single cell will contain a bubble [0.0 - 1.0]
This method should be called only once and before the game starts.

void BubbleField::addBubble ( Bubble bubble,
Templates::CallableBack< BubbleField > *  addBubbleDone 
)

Adds bubble to the field.

Parameters:
[in] bubble Bubble to be added to the field
[in] addBubbleDone Object on which the "action performed" method should be called when the bubble is successfully added
Adds given bubble to the playfield. The given bubble should have coordinates in bubble field coordinates system for which method isInCollision() returns true

bool BubbleField::isInCollision ( const SbVec3f &  position  ) 

Check for a collision.

Parameters:
[in] position Position of a bubble which should be checked if it hasn't collided. Note that the position vector coordinates are treated as if they were in bubble field coordinates system.
Returnes if the bubble on given coordinates has collided

static unsigned BubbleField::getNumberOfBubblesInRow (  )  [inline, static]

Returns the number of bubbles in one row.

References BUBBLES_IN_ROW.

Referenced by Bubble::getRadius().

virtual void BubbleField::timeUpdate ( float  dt  )  [virtual]

Timer value change event occured.

This method is called on each timer value change.

Parameters:
[in] dt Time difference between the last call (delta).

Implements TimeUpdateable.

virtual void BubbleField::callableBackNotify ( Bubble subject  )  [virtual]

Subject performed action on which the callback was defined.

Parameters:
[in] subject Object that perfmored the action.

Implements Templates::CallableBack< Bubble >.


Member Data Documentation

const unsigned BubbleField::BUBBLES_IN_ROW [static, private]

Number of bubbles in one row.

Referenced by getNumberOfBubblesInRow().

Content of the field.

Object on which the "action performed" method should be called when a bubble is added to the field

std::list<Bubble *> BubbleField::_explodingBubbles [private]

Container to store bubbles that are exploding at the moment.

Stores the number of bubbles that are exploding at the moment.

Stores falling bubbles because they are not connected to the rear wall.

void(* BubbleField::_successGameEndFunc)() [private]

Function that should be called on successfull game end.


The documentation for this class was generated from the following file:

Generated on Sat Dec 20 19:21:24 2008 for PGR2008 by  doxygen 1.5.6