cmdfx 0.2.1
Lightweight game engine for your terminal
Loading...
Searching...
No Matches
engine.hpp
Go to the documentation of this file.
1
11#pragma once
12
13extern "C" {
14 #include "cmdfx/physics/engine.h"
15}
16
19
20namespace CmdFX {
21
25 namespace Engine {
26 int start() {
27 return Engine_start();
28 }
29
39 std::vector<std::unique_ptr<Sprite>> tick() {
40 CmdFX_Sprite** modifiedSprites = Engine_tick();
41 std::vector<std::unique_ptr<Sprite>> sprites;
42
43 for (int i = 0; modifiedSprites[i] != nullptr; i++) {
44 sprites.emplace_back(std::make_unique<Sprite>(modifiedSprites[i]));
45 }
46
47 return sprites;
48 }
49
50 void cleanup() {
52 }
53
55 return Engine_isMotionDebugEnabled() != 0;
56 }
57
58 bool isSpriteStatic(Sprite& sprite) {
59 return Sprite_isStatic(sprite.getSprite()) != 0;
60 }
61
62 void setSpriteStatic(Sprite& sprite, bool isStatic) {
63 Sprite_setStatic(sprite.getSprite(), isStatic ? 1 : 0);
64 }
65
66 double getForceOfGravity() {
68 }
69
70 void setForceOfGravity(double force) {
72 }
73
74 double getTerminalVelocity() {
76 }
77
78 void setTerminalVelocity(double velocity) {
80 }
81
82 int getGroundY() {
83 return Engine_getGroundY();
84 }
85
86 void setGroundY(int y) {
88 }
89
90 double getDefaultFrictionCoefficient() {
92 }
93
94 void setDefaultFrictionCoefficient(double coefficient) {
96 }
97
98 double getCharacterMass(char c) {
100 }
101
102 void setCharacterMass(char c, double mass) {
104 }
105 };
106
107}
A C++ wrapper around a CmdFX_Sprite struct.
Definition sprites.hpp:32
CmdFX_Sprite * getSprite()
Get the Sprite object associated with this class.
Definition sprites.hpp:53
Global physics engine declarations.
double Engine_getTerminalVelocity()
Gets the terminal velocity, in characters per second.
double Engine_getDefaultFrictionCoefficient()
Gets the default friction coefficient for a sprite.
int Engine_setGroundY(int y)
Sets the Y level of the ground for the physics engine.
double Engine_getCharacterMass(char c)
Gets the default mass of a character.
int Engine_setCharacterMass(char c, double mass)
Sets the default mass of a character.
int Engine_getGroundY()
Gets the Y level of the ground for the physics engine.
int Sprite_isStatic(CmdFX_Sprite *sprite)
Gets whether this sprite is static.
int Engine_cleanup()
Cleans up the physics engine.
int Engine_setTerminalVelocity(double velocity)
Sets the terminal velocity, in characters per second.
int Sprite_setStatic(CmdFX_Sprite *sprite, int isStatic)
Sets whether this sprite is static.
int Engine_setForceOfGravity(double force)
Sets the force of gravity, in characters per second squared.
CmdFX_Sprite ** Engine_tick()
Ticks the physics engine.
double Engine_getForceOfGravity()
Gets the force of gravity, in characters per second squared.
int Engine_start()
Starts up the physics engine.
int Engine_setDefaultFrictionCoefficient(double coefficient)
Sets the default friction coefficient for a sprite.
int Engine_isMotionDebugEnabled()
Whether motion debugging is enabled.
C++ Extensions for velocity and acceleration functions.
A C++ wrapper around the CmdFX Physics Engine.
Definition engine.hpp:25
bool isMotionDebugEnabled()
Checks if motion debugging is enabled.
Definition engine.hpp:54
std::vector< std::unique_ptr< Sprite > > tick()
Ticks the physics engine and returns modified sprites.
Definition engine.hpp:39
Primary namespace for CmdFX.
Definition cmdfx.hpp:22
C++ Extensions for the CmdFX Sprites API.
Represents a sprite that can be drawn to the terminal.
Definition sprites.h:30