32class SpriteMotion final {
34 std::unique_ptr<Sprite> sprite;
37 SpriteMotion(std::unique_ptr<Sprite> sprite) : sprite(std::move(sprite)) {
40 : sprite(std::make_unique<Sprite>(sprite)) {
72 std::vector<double> motion;
77 for (
int i = 0; i < 4; ++i) {
78 motion.push_back(arr[i]);
85 double getVelocityX() {
89 int setVelocityX(
double velocity) {
93 double getVelocityY() {
97 int setVelocityY(
double velocity) {
101 double getAccelerationX() {
105 int setAccelerationX(
double acceleration) {
109 double getAccelerationY() {
113 int setAccelerationY(
double acceleration) {
117 bool isAboutToCollide(Sprite& sprite2) {
119 sprite->getSprite(), sprite2.getSprite()
123 bool isAboutToCollide(
const std::unique_ptr<Sprite>& sprite2) {
125 sprite->getSprite(), sprite2->getSprite()
129 std::vector<std::unique_ptr<Sprite>> getAboutToCollideSprites() {
130 std::vector<std::unique_ptr<Sprite>> sprites;
134 for (
int i = 0; arr[i] !=
nullptr; ++i) {
135 sprites.emplace_back(std::make_unique<Sprite>(arr[i]));
141 int resetAllMotion() {
std::vector< double > getMotion()
Gets the motion array of a sprite as a vector.
Definition motion.hpp:71
Velocity and Acceleration functions.
double Sprite_getAccelerationY(CmdFX_Sprite *sprite)
Gets the Y acceleration of a sprite.
int Sprite_setAccelerationY(CmdFX_Sprite *sprite, double acceleration)
Sets the Y acceleration of a sprite.
double Sprite_getVelocityY(CmdFX_Sprite *sprite)
Gets the Y velocity of a sprite.
int Sprite_isAboutToCollide(CmdFX_Sprite *sprite1, CmdFX_Sprite *sprite2)
Whether a sprite is about to collide with another sprite.
double * Sprite_getMotion(CmdFX_Sprite *sprite)
Gets the motion array of a sprite.
void Engine_enableMotionDebug()
Enables motion debugging.
int Sprite_setVelocityX(CmdFX_Sprite *sprite, double velocity)
Sets the X velocity of a sprite.
int Sprite_setVelocityY(CmdFX_Sprite *sprite, double velocity)
Sets the Y velocity of a sprite.
CmdFX_Sprite ** Sprite_getAboutToCollideSprites(CmdFX_Sprite *sprite)
Gets all of the sprites the sprite is about to collide with.
double Sprite_getVelocityX(CmdFX_Sprite *sprite)
Gets the X velocity of a sprite.
int Sprite_setAccelerationX(CmdFX_Sprite *sprite, double acceleration)
Sets the X acceleration of a sprite.
double Sprite_getAccelerationX(CmdFX_Sprite *sprite)
Gets the X acceleration of a sprite.
void Engine_disableMotionDebug()
Disables motion debugging.
int Sprite_resetAllMotion(CmdFX_Sprite *sprite)
Resets all motion of a sprite.
int Engine_isMotionDebugEnabled()
Whether motion debugging is enabled.
A C++ wrapper around the CmdFX Physics Engine.
Definition engine.hpp:27
bool isMotionDebugEnabled()
Checks if motion debugging is enabled.
Definition motion.hpp:160
void disableMotionDebug()
Disables motion debugging.
Definition motion.hpp:177
void enableMotionDebug()
Enables motion debugging.
Definition motion.hpp:170
Primary namespace for CmdFX.
Definition cmdfx.hpp:26
struct CmdFX_Sprite CmdFX_Sprite
Represents a sprite that can be drawn to the terminal.
C++ Extensions for the CmdFX Sprites API.
Represents a sprite that can be drawn to the terminal.
Definition sprites.h:31