From 3d2428af8e8d9d49b4ade52d4806a7dae4cf1ab8 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Thu, 7 Nov 2024 20:03:14 +0100 Subject: merge #25 + nitpicking --- src/crepe/api/Rigidbody.cpp | 2 +- src/crepe/api/Rigidbody.h | 13 ++++++------- src/crepe/api/Sprite.cpp | 4 ++-- src/crepe/api/Sprite.h | 7 ++++--- src/crepe/api/Transform.cpp | 8 +++----- src/crepe/api/Transform.h | 4 ++-- src/crepe/system/PhysicsSystem.cpp | 2 +- src/crepe/types.h | 1 - 8 files changed, 19 insertions(+), 22 deletions(-) (limited to 'src/crepe') 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 image, const Color & color, - const FlipSettings & flip) +Sprite::Sprite(game_object_id_t id, shared_ptr 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 image, const Color & color, const FlipSettings & flip); + Sprite(game_object_id_t id, std::shared_ptr image, + const Color & color, const FlipSettings & flip); ~Sprite(); std::shared_ptr 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 - #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; } - -- cgit v1.2.3