Raylib Bubbles
C++11 Raylib bubble shooter game.
GameActionMgr::ActionType Struct Reference

Represents an action to be taken by the game. More...

#include <action.hpp>

Public Types

enum class  Effect { STATIC , KINEMATIC , BOUNCE , BUBBLE }
 Selects the effect logic of an action.
 
enum class  PruneType { OOB_BOARD , OOB_WINDOW }
 Selects the type of pruning to be used by an action.
 

Public Member Functions

 ActionType (const Effect effect, const PruneType pruneType, const AnimState &animData, GameActionMgr *mgr)
 internally assigned. More...
 
void step (const float scale=1.0f)
 Steps the action forward, according to the chosen effect logic. More...
 
bool shouldPrune () const
 Checks if the action should be pruned. More...
 
bool repeated (const size_t row, const size_t col)
 Provides a boolean condition against repeat use of same row-column. More...
 

Public Attributes

GameActionMgrparent
 
AnimState obj
 
Effect effect
 
PruneType pruneType
 
bool pruneFlag
 
size_t id
 

Detailed Description

Represents an action to be taken by the game.

This struct is used to represent an action that can be taken by the game, such as launching a bubble. It keeps a pointer (previously reference) to its parent GameActionMgr object, which allows it to have data about the game board and window.

Note
This struct is not meant to be used directly, but rather through constructing an instance in enqueue() from the GameActionMgr class.

Constructor & Destructor Documentation

◆ ActionType()

GameActionMgr::ActionType::ActionType ( const Effect  effect,
const PruneType  pruneType,
const AnimState animData,
GameActionMgr mgr 
)
inline

internally assigned.

Constructs an action with the given effect and bubble data.

Parameters
effectThe effect logic to be used by the action.
pruneTypeThe type of pruning to be used by the action.
animDataAn AnimState object that represents the animation.
mgrA pointer to the GameActionMgr object that created this action.

Member Function Documentation

◆ repeated()

bool GameActionMgr::ActionType::repeated ( const size_t  row,
const size_t  col 
)

Provides a boolean condition against repeat use of same row-column.

Parameters
rowThe row to check.
colThe column to check.
Returns
True if the row-column being checked is the same as the last checked one, false otherwise.
See also
GameBoard, GameUtils

◆ shouldPrune()

bool GameActionMgr::ActionType::shouldPrune ( ) const

Checks if the action should be pruned.

Pruning is done when the action becomes irrelevant, such as moving off screen or off board, finishing its animation, etc. Detecting off screen coordinates is built-in to the method, but any other condition can mark the action for pruning, by using the pruneFlag member variable. This method should be called after step() to ensure the action is pruned only when it should be.

Note
Since there may be actions handling multiple bubbles, this method checks if all bubbles in the action have moved off screen by default, leaving more advanced pruning to be marked by pruneFlag.
Returns
True if the action should be pruned (including pruneFlag being raised), false otherwise.

◆ step()

void GameActionMgr::ActionType::step ( const float  scale = 1.0f)

Steps the action forward, according to the chosen effect logic.

The step method of each instance of this class allows stepping the action forward, according to the chosen effect logic. Certain effects may require additional data to be passed to the method, such as the game board or window dimensions, to properly interact with the game state. To do so, the constructor given parameters are referenced/stored in the instance, enabling external interaction with further game objects.

Please look at the source of this method for a clearer example of this mechanic.

Parameters
scaleThe scale to step the action by, for delta time calculations.
Warning
If the action effect is a bubble, the bouncing will be bounded to the board dimensions EVEN OUTSIDE THE BOARD. This way, it is easier to setup graphics for the game such as borders and other girders.
Todo:
Make two horizontally separate points that must both be in the same bubble cell for better bubble collisions.
See also
Effect

The documentation for this struct was generated from the following files: