5 #include <unordered_set>
67 AnimState(
const float x,
const float y,
const float xVel,
const float yVel,
const AnimType type,
const size_t hue,
const ssize_t duration,
const bool hasGravity)
68 : x(x), y(y), xVel(xVel), yVel(yVel), type(type), hue(hue), duration(duration), hasGravity(hasGravity) {};
73 static AnimState bubble(
const float x,
const float y,
const float xVel,
const float yVel,
const size_t hue) {
74 return AnimState(x, y, xVel, yVel, AnimType::BUBBLE, hue, -1,
false);
77 static AnimState gravityBubble(
const float x,
const float y,
const float xVel,
const float yVel,
const size_t hue) {
78 return AnimState(x, y, xVel, yVel, AnimType::BUBBLE, hue, -1,
true);
81 static AnimState particle(
const float x,
const float y,
const float xVel,
const float yVel,
const ssize_t duration) {
82 return AnimState(x, y, xVel, yVel, AnimType::PARTICLE, 0, duration,
false);
85 static AnimState gravityParticle(
const float x,
const float y,
const float xVel,
const float yVel,
const ssize_t duration) {
86 return AnimState(x, y, xVel, yVel, AnimType::PARTICLE, 0, duration,
true);
138 : effect(effect), parent(mgr), obj(animData), pruneType(pruneType), pruneFlag(false) {};
156 void step(
const float scale = 1.0f);
197 std::vector<ActionType>::iterator
begin() {
198 return actions.begin();
205 std::vector<ActionType>::iterator
end() {
206 return actions.end();
231 size_t enqueue(ActionType action);
238 void step(
const float scale = 1.0f);
252 bool find(
const size_t id)
const;
258 const size_t MAX_IDS;
261 std::vector<ActionType> actions;
262 std::unordered_set<size_t> ids;
Manages game actions and allows them to interact with the game board if necessary.
Definition: action.hpp:22
bool find(const size_t id) const
Checks if an action is still ongoing (was not pruned).
Definition: action.cpp:88
size_t enqueue(ActionType action)
Adds an action to the manager.
Definition: action.cpp:66
void step(const float scale=1.0f)
Steps all managed actions forward, by calling their step() methods.
Definition: action.cpp:74
size_t size() const
Returns the number of actions currently in the manager.
Definition: action.cpp:62
std::vector< ActionType >::iterator end()
Builds an iterator to the end of the actions container.
Definition: action.hpp:205
void prune()
Prunes all actions that are no longer needed, using their shouldPrune() methods.
Definition: action.cpp:79
GameActionMgr(PlacedBoard &boardData)
Constructs a GameActionMgr object with the given dimensions and a reference to the game board.
Definition: action.cpp:5
std::vector< ActionType >::iterator begin()
Builds an iterator to the beginning of the actions container.
Definition: action.hpp:197
Represents an action to be taken by the game.
Definition: action.hpp:101
Effect
Selects the effect logic of an action.
Definition: action.hpp:107
bool shouldPrune() const
Checks if the action should be pruned.
Definition: action.cpp:53
bool repeated(const size_t row, const size_t col)
Provides a boolean condition against repeat use of same row-column.
void step(const float scale=1.0f)
Steps the action forward, according to the chosen effect logic.
Definition: action.cpp:13
ActionType(const Effect effect, const PruneType pruneType, const AnimState &animData, GameActionMgr *mgr)
internally assigned.
Definition: action.hpp:137
PruneType
Selects the type of pruning to be used by an action.
Definition: action.hpp:118
Represents the state of an object to be animated.
Definition: action.hpp:33
AnimState(const float x, const float y, const float xVel, const float yVel, const AnimType type, const size_t hue, const ssize_t duration, const bool hasGravity)
Constructs an animation state with the given data.
Definition: action.hpp:67
AnimType
Selects the type of object being animated, to later determine what to draw.
Definition: action.hpp:40
Describes a game board placed in a window.
Definition: pboard.hpp:16