aboutsummaryrefslogtreecommitdiff
path: root/src/crepe
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe')
-rw-r--r--src/crepe/api/Rigidbody.cpp2
-rw-r--r--src/crepe/api/Rigidbody.h13
-rw-r--r--src/crepe/api/Sprite.cpp4
-rw-r--r--src/crepe/api/Sprite.h7
-rw-r--r--src/crepe/api/Transform.cpp8
-rw-r--r--src/crepe/api/Transform.h4
-rw-r--r--src/crepe/system/PhysicsSystem.cpp2
-rw-r--r--src/crepe/types.h1
8 files changed, 19 insertions, 22 deletions
diff --git a/src/crepe/api/Rigidbody.cpp b/src/crepe/api/Rigidbody.cpp
index 0de9846..cbf1325 100644
--- a/src/crepe/api/Rigidbody.cpp
+++ b/src/crepe/api/Rigidbody.cpp
@@ -2,7 +2,7 @@
using namespace crepe;
-crepe::Rigidbody::Rigidbody(uint32_t game_object_id, const RigidbodyData & data)
+crepe::Rigidbody::Rigidbody(uint32_t game_object_id, const Data & data)
: Component(game_object_id), data(data) {}
void crepe::Rigidbody::add_force_linear(const Vector2 & force) {
diff --git a/src/crepe/api/Rigidbody.h b/src/crepe/api/Rigidbody.h
index b12cf1d..68481f4 100644
--- a/src/crepe/api/Rigidbody.h
+++ b/src/crepe/api/Rigidbody.h
@@ -37,21 +37,20 @@ public:
*/
struct PhysicsConstraints {
//! X constraint
- bool x = 0;
+ bool x = false;
//! Y constraint
- bool y = 0;
+ bool y = false;
//! rotation constraint
- bool rotation = 0;
+ bool rotation = false;
};
public:
/**
- *
* \brief struct for Rigidbody data
*
* This struct holds the data for the Rigidbody.
*/
- struct RigidbodyData {
+ struct Data {
//! objects mass
double mass = 0.0;
//! gravtiy scale
@@ -83,9 +82,9 @@ public:
* \param game_object_id id of the gameobject the rigibody is added to.
* \param data struct to configure the rigidbody.
*/
- Rigidbody(uint32_t game_object_id, const RigidbodyData & data);
+ Rigidbody(uint32_t game_object_id, const Data & data);
//! struct to hold data of rigidbody
- RigidbodyData data;
+ Data data;
public:
/**
diff --git a/src/crepe/api/Sprite.cpp b/src/crepe/api/Sprite.cpp
index 7e810b5..d3465c7 100644
--- a/src/crepe/api/Sprite.cpp
+++ b/src/crepe/api/Sprite.cpp
@@ -10,8 +10,8 @@
using namespace std;
using namespace crepe;
-Sprite::Sprite(game_object_id_t id, shared_ptr<Texture> image, const Color & color,
- const FlipSettings & flip)
+Sprite::Sprite(game_object_id_t id, shared_ptr<Texture> image,
+ const Color & color, const FlipSettings & flip)
: Component(id), color(color), flip(flip), sprite_image(image) {
dbg_trace();
}
diff --git a/src/crepe/api/Sprite.h b/src/crepe/api/Sprite.h
index 28078cd..00dcb27 100644
--- a/src/crepe/api/Sprite.h
+++ b/src/crepe/api/Sprite.h
@@ -12,14 +12,15 @@
namespace crepe {
struct FlipSettings {
- bool flip_x = 1;
- bool flip_y = 1;
+ bool flip_x = true;
+ bool flip_y = true;
};
class Sprite : public Component {
public:
- Sprite(game_object_id_t id, std::shared_ptr<Texture> image, const Color & color, const FlipSettings & flip);
+ Sprite(game_object_id_t id, std::shared_ptr<Texture> image,
+ const Color & color, const FlipSettings & flip);
~Sprite();
std::shared_ptr<Texture> sprite_image;
Color color;
diff --git a/src/crepe/api/Transform.cpp b/src/crepe/api/Transform.cpp
index a5f29ea..a244bc5 100644
--- a/src/crepe/api/Transform.cpp
+++ b/src/crepe/api/Transform.cpp
@@ -1,13 +1,11 @@
-#include <cstdint>
-
#include "util/log.h"
#include "Transform.h"
using namespace crepe;
-Transform::Transform(game_object_id_t id, const Vector2 & point, double rot,
- double scale)
- : Component(id), position(point), rotation(rot), scale(scale) {
+Transform::Transform(game_object_id_t id, const Vector2 & point,
+ double rotation, double scale)
+ : Component(id), position(point), rotation(rotation), scale(scale) {
dbg_trace();
}
diff --git a/src/crepe/api/Transform.h b/src/crepe/api/Transform.h
index 805553e..d7a5b8a 100644
--- a/src/crepe/api/Transform.h
+++ b/src/crepe/api/Transform.h
@@ -17,10 +17,10 @@ public:
/**
* \param id The id of the GameObject this component belongs to
* \param point The position of the GameObject
- * \param rot The rotation of the GameObject
+ * \param rotation The rotation of the GameObject
* \param scale The scale of the GameObject
*/
- Transform(game_object_id_t id, const Vector2 & point, double rot,
+ Transform(game_object_id_t id, const Vector2 & point, double rotation,
double scale);
/**
* \brief Get the maximum number of instances for this component
diff --git a/src/crepe/system/PhysicsSystem.cpp b/src/crepe/system/PhysicsSystem.cpp
index 1bd2171..eb54ad3 100644
--- a/src/crepe/system/PhysicsSystem.cpp
+++ b/src/crepe/system/PhysicsSystem.cpp
@@ -20,7 +20,7 @@ void PhysicsSystem::update() {
double gravity = Config::get_instance().physics.gravity;
for (Rigidbody & rigidbody : rigidbodies) {
if (!rigidbody.active) continue;
-
+
switch (rigidbody.data.body_type) {
case Rigidbody::BodyType::DYNAMIC:
for (Transform & transform : transforms) {
diff --git a/src/crepe/types.h b/src/crepe/types.h
index 5ae2c81..0d459e8 100644
--- a/src/crepe/types.h
+++ b/src/crepe/types.h
@@ -7,4 +7,3 @@ namespace crepe {
typedef uint32_t game_object_id_t;
}
-