Raylib Bubbles
C++11 Raylib bubble shooter game.
|
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 | |
GameActionMgr * | parent |
AnimState | obj |
Effect | effect |
PruneType | pruneType |
bool | pruneFlag |
size_t | id |
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.
|
inline |
internally assigned.
Constructs an action with the given effect and bubble data.
effect | The effect logic to be used by the action. |
pruneType | The type of pruning to be used by the action. |
animData | An AnimState object that represents the animation. |
mgr | A pointer to the GameActionMgr object that created this action. |
bool GameActionMgr::ActionType::repeated | ( | const size_t | row, |
const size_t | col | ||
) |
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.
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.
scale | The scale to step the action by, for delta time calculations. |