#include <bubble_field.h>

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< BubblePlate > | FieldContent |
Private Member Functions | |
| BubbleField (const BubbleField &) | |
| BubbleField & | operator= (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< Coordinates > | getNeighboursCoords (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... | |
This class represents "glued-on" bubbles on the rear wall of the play field.
Reference object (cannot be copied).
typedef Bubble*** BubbleField::BubblePlate [private] |
Types used in for the field content.
typedef std::vector<BubblePlate> BubbleField::FieldContent [private] |
| BubbleField::BubbleField | ( | const BubbleField & | ) | [private] |
| BubbleField::BubbleField | ( | ) |
Default constructor.
| BubbleField::~BubbleField | ( | ) |
Destructor.
| 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.
| [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.
| [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.
| [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.
| [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.
| [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.
| [in] | bubble | Given bubble |
| void BubbleField::solveCollisionWithBubble | ( | Bubble * | bubble | ) | [private] |
Solves collision of the given bubble with the wall.
| [in] | bubble | Given bubble |
| void BubbleField::destroyBubblesInCluster | ( | const Coordinates & | position | ) | [private] |
Remove bubbles of the same type in one cluster.
| [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.
| [in] | bubble | Given bubble |
Returns vector of bubbles that are in collision with given bubble.
| [in] | bubble | Given bubble |
| std::list<Coordinates> BubbleField::getNeighboursCoords | ( | const Coordinates & | coords | ) | const [private] |
Returns list of Coordinates that are neighbours' positions.
| [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.
| [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 |
| void BubbleField::addNeighboursTowardsWall | ( | const BubbleGenerator * | bubbleGen, | |
| const Coordinates & | coords | |||
| ) | [private] |
Recursively adds neighbours towards the rear wall until the wall is hit.
| [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.
| [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.
| [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.
| [in] | oiCoord | OI X (or Y) coordinate value |
| [in] | plate | Plate index |
| [in] | roundFunc | Rounding function (roundf, floor, ceil, ...) |
| static unsigned BubbleField::oiZCoordinateToLocal | ( | float | oiCoord, | |
| float(*)(float) | roundFunc = roundf | |||
| ) | [static, private] |
Transforms z-axis OI coordinate into a local coordinate.
| [in] | oiCoord | Z coordinate value |
| [in] | roundFunc | Rounding function (roundf, floor, ceil, ...) |
| static SbVec3f BubbleField::localCoordinatesToOI | ( | unsigned | plate, | |
| unsigned | x, | |||
| unsigned | y | |||
| ) | [static, private] |
Transforms local coordinates to these in OI.
| [in] | plate | Plate index |
| [in] | x | Local X coordinate |
| [in] | y | Local Y coordinate |
| static SbVec3f BubbleField::localCoordinatesToOI | ( | Coordinates | local | ) | [static, private] |
Transforms local coordinates to these in OI.
| [in] | local | Local coordinates |
| void BubbleField::setOnSuccessfullGameEndCallback | ( | void(*)() | callback | ) |
Set callback that should be called on successfull game end.
| callback | Callback to be set. |
| void BubbleField::generateStartingLayout | ( | const BubbleGenerator * | bubbleGen, | |
| unsigned | numOfInitiallyFilledPlates, | |||
| float | probCellContainBubble | |||
| ) |
Generates starting layout.
| [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] |
| void BubbleField::addBubble | ( | Bubble * | bubble, | |
| Templates::CallableBack< BubbleField > * | addBubbleDone | |||
| ) |
Adds bubble to the field.
| [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 |
| bool BubbleField::isInCollision | ( | const SbVec3f & | position | ) |
Check for a collision.
| [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. |
| 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.
| [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.
| [in] | subject | Object that perfmored the action. |
Implements Templates::CallableBack< Bubble >.
const unsigned BubbleField::BUBBLES_IN_ROW [static, private] |
FieldContent BubbleField::_content [private] |
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.
int BubbleField::_explodingBubblesCount [private] |
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.
1.5.6