![]() |
cmdfx 0.2.1
Lightweight game engine for your terminal
|
A C++ wrapper around a CmdFX_Sprite struct for motion-related functions. More...
#include <motion.hpp>
Public Member Functions | |
SpriteMotion (std::unique_ptr< Sprite > sprite) | |
SpriteMotion (CmdFX_Sprite *sprite) | |
std::vector< double > | getMotion () |
Gets the motion array of a sprite as a vector. | |
double | getVelocityX () |
int | setVelocityX (double velocity) |
double | getVelocityY () |
int | setVelocityY (double velocity) |
double | getAccelerationX () |
int | setAccelerationX (double acceleration) |
double | getAccelerationY () |
int | setAccelerationY (double acceleration) |
bool | isAboutToCollide (Sprite &sprite2) |
bool | isAboutToCollide (std::unique_ptr< Sprite > sprite2) |
std::vector< std::unique_ptr< Sprite > > | getAboutToCollideSprites () |
int | resetAllMotion () |
A C++ wrapper around a CmdFX_Sprite struct for motion-related functions.
This class provides methods to get and set the velocity and acceleration of a sprite, check for potential collisions, and reset the motion of a sprite. The destructor will reset all motion when the object is destroyed.
|
inline |
Gets the motion array of a sprite as a vector.
The motion array is the internal array that stores the velocity and acceleration of a sprite. The motion array is a 4-element array, where the elements are:
The motion array is used by the physics engine to calculate the motion of a sprite. The array is freed from Sprite_resetAllMotion
and Sprite_free
, so it should not be freed manually.
sprite | The sprite to use. |