aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-24 10:46:32 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-24 10:46:32 +0200
commit5447ddd896eb49ea9fd9f9191a277fd1d5730aa3 (patch)
tree96e09b8fb5d757aafef33da50a93204bae54ba9f /src/crepe/api
parent0b08b742fffa63188c89d760a5aecd55d585403b (diff)
add PR #9 comments as code comments
Diffstat (limited to 'src/crepe/api')
-rw-r--r--src/crepe/api/Color.cpp1
-rw-r--r--src/crepe/api/Color.h2
-rw-r--r--src/crepe/api/Force.cpp4
-rw-r--r--src/crepe/api/ParticleEmitter.cpp8
-rw-r--r--src/crepe/api/Rigidbody.h1
-rw-r--r--src/crepe/api/Texture.h3
-rw-r--r--src/crepe/api/Transform.h13
7 files changed, 25 insertions, 7 deletions
diff --git a/src/crepe/api/Color.cpp b/src/crepe/api/Color.cpp
index 71592da..fb5bd1a 100644
--- a/src/crepe/api/Color.cpp
+++ b/src/crepe/api/Color.cpp
@@ -11,6 +11,7 @@ Color Color::cyan = Color(0, 255, 255, 0);
Color Color::yellow = Color(255, 255, 0, 0);
Color Color::magenta = Color(255, 0, 255, 0);
+// FIXME: do we really need double precision for color values?
Color::Color(double red, double green, double blue, double alpha) {
this->a = alpha;
this->r = red;
diff --git a/src/crepe/api/Color.h b/src/crepe/api/Color.h
index 207434e..36d91ef 100644
--- a/src/crepe/api/Color.h
+++ b/src/crepe/api/Color.h
@@ -4,6 +4,8 @@ namespace crepe::api {
class Color {
+ // FIXME: can't these colors be defined as a `static constexpr const Color`
+ // instead?
public:
Color(double red, double green, double blue, double alpha);
static const Color & get_white();
diff --git a/src/crepe/api/Force.cpp b/src/crepe/api/Force.cpp
index 98649c1..e359adc 100644
--- a/src/crepe/api/Force.cpp
+++ b/src/crepe/api/Force.cpp
@@ -6,6 +6,10 @@ namespace crepe::api {
Force::Force(uint32_t game_object_id, uint32_t magnitude, uint32_t direction)
: Component(game_object_id) {
+ // TODO: A standard angle unit should be established for the entire engine
+ // and assumed to be the default everywhere. Only conversion functions should
+ // explicitly contain the unit (i.e. `deg_to_rad()` & `rad_to_deg()`)
+
// Convert direction from degrees to radians
float radian_direction = static_cast<float>(direction) * (M_PI / 180.0f);
force_x = static_cast<int32_t>(
diff --git a/src/crepe/api/ParticleEmitter.cpp b/src/crepe/api/ParticleEmitter.cpp
index 2e07562..0b3a9ee 100644
--- a/src/crepe/api/ParticleEmitter.cpp
+++ b/src/crepe/api/ParticleEmitter.cpp
@@ -18,9 +18,11 @@ ParticleEmitter::ParticleEmitter(uint32_t game_object_id,
std::srand(
static_cast<uint32_t>(std::time(nullptr))); // initialize random seed
std::cout << "Create emitter" << std::endl;
- min_angle = (360 + angle - (angleOffset % 360)) % 360; // calculate minAngle
- max_angle = (360 + angle + (angleOffset % 360)) % 360; // calculate maxAngle
- position.x = 400;
+ // FIXME: Why do these expressions start with `360 +`, only to be `% 360`'d
+ // right after? This does not make any sense to me.
+ min_angle = (360 + angle - (angleOffset % 360)) % 360;
+ max_angle = (360 + angle + (angleOffset % 360)) % 360;
+ position.x = 400; // FIXME: what are these magic values?
position.y = 400;
for (size_t i = 0; i < max_particles; i++) {
this->particles.emplace_back();
diff --git a/src/crepe/api/Rigidbody.h b/src/crepe/api/Rigidbody.h
index 05cbb03..6079a76 100644
--- a/src/crepe/api/Rigidbody.h
+++ b/src/crepe/api/Rigidbody.h
@@ -6,6 +6,7 @@
namespace crepe::api {
+// FIXME: can't this enum be defined inside the class declaration of Rigidbody?
enum class BodyType {
//! Does not move (e.g. walls, ground ...)
STATIC,
diff --git a/src/crepe/api/Texture.h b/src/crepe/api/Texture.h
index 7a2c755..f8481e3 100644
--- a/src/crepe/api/Texture.h
+++ b/src/crepe/api/Texture.h
@@ -1,5 +1,8 @@
#pragma once
+// FIXME: this header can't be included because this is an API header, and SDL2
+// development headers won't be bundled with crepe. Why is this facade in the
+// API namespace?
#include <SDL2/SDL_render.h>
#include <memory>
diff --git a/src/crepe/api/Transform.h b/src/crepe/api/Transform.h
index 7b74e43..c17ae34 100644
--- a/src/crepe/api/Transform.h
+++ b/src/crepe/api/Transform.h
@@ -9,13 +9,18 @@
namespace crepe::api {
class Transform : public Component {
-
+ // FIXME: What's the difference between the `Point` and `Position`
+ // classes/structs? How about we replace both with a universal `Vec2` that
+ // works similar (or the same) as those found in GLSL?
public:
Transform(uint32_t id, Point &, double, double);
~Transform();
- Point position; // Translation (shift)
- double rotation; // Rotation, in radians
- double scale; // Multiplication factoh
+ //! Translation (shift)
+ Point position;
+ //! Rotation, in radians
+ double rotation;
+ //! Multiplication factor
+ double scale;
};
} // namespace crepe::api