aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-23 22:23:36 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-23 22:23:36 +0200
commit6e2c5e1b57210b10f8781f103e5c46308544339f (patch)
tree9738592f2082de1881a0ea019bf3c99644134aef /src/crepe/api
parent9b7be419c9dcc6ebd1e504713c7b2676ca3d2fdf (diff)
more nitpicking
Diffstat (limited to 'src/crepe/api')
-rw-r--r--src/crepe/api/AssetManager.cpp3
-rw-r--r--src/crepe/api/AssetManager.h1
-rw-r--r--src/crepe/api/AudioSource.cpp5
-rw-r--r--src/crepe/api/BehaviorScript.hpp1
-rw-r--r--src/crepe/api/CircleCollider.h4
-rw-r--r--src/crepe/api/Color.cpp2
-rw-r--r--src/crepe/api/Force.cpp11
-rw-r--r--src/crepe/api/Force.h6
-rw-r--r--src/crepe/api/ParticleEmitter.cpp35
-rw-r--r--src/crepe/api/ParticleEmitter.h44
-rw-r--r--src/crepe/api/Rigidbody.cpp4
-rw-r--r--src/crepe/api/Rigidbody.h16
-rw-r--r--src/crepe/api/Sprite.cpp11
-rw-r--r--src/crepe/api/Sprite.h9
-rw-r--r--src/crepe/api/Texture.cpp19
-rw-r--r--src/crepe/api/Texture.h5
-rw-r--r--src/crepe/api/Transform.cpp8
-rw-r--r--src/crepe/api/Transform.h9
18 files changed, 107 insertions, 86 deletions
diff --git a/src/crepe/api/AssetManager.cpp b/src/crepe/api/AssetManager.cpp
index bf4217f..560df6c 100644
--- a/src/crepe/api/AssetManager.cpp
+++ b/src/crepe/api/AssetManager.cpp
@@ -1,7 +1,6 @@
-
+#include "util/log.h"
#include "AssetManager.h"
-#include "util/log.h"
using namespace crepe::api;
diff --git a/src/crepe/api/AssetManager.h b/src/crepe/api/AssetManager.h
index f3f1307..d9d9b44 100644
--- a/src/crepe/api/AssetManager.h
+++ b/src/crepe/api/AssetManager.h
@@ -43,4 +43,5 @@ public:
return new_asset;
}
};
+
} // namespace crepe::api
diff --git a/src/crepe/api/AudioSource.cpp b/src/crepe/api/AudioSource.cpp
index 10b3b49..35b8d83 100644
--- a/src/crepe/api/AudioSource.cpp
+++ b/src/crepe/api/AudioSource.cpp
@@ -1,9 +1,8 @@
#include <memory>
-#include "AudioSource.h"
-
#include "../Sound.h"
-#include <memory>
+
+#include "AudioSource.h"
using namespace crepe::api;
diff --git a/src/crepe/api/BehaviorScript.hpp b/src/crepe/api/BehaviorScript.hpp
index a6bd81c..6fdf605 100644
--- a/src/crepe/api/BehaviorScript.hpp
+++ b/src/crepe/api/BehaviorScript.hpp
@@ -3,6 +3,7 @@
#include <type_traits>
#include "../util/log.h"
+
#include "BehaviorScript.h"
namespace crepe::api {
diff --git a/src/crepe/api/CircleCollider.h b/src/crepe/api/CircleCollider.h
index 96d98ed..762574b 100644
--- a/src/crepe/api/CircleCollider.h
+++ b/src/crepe/api/CircleCollider.h
@@ -5,8 +5,8 @@ namespace crepe::api {
class CircleCollider : public Collider {
public:
- CircleCollider(uint32_t gameObjectId, int radius)
- : Collider(gameObjectId), radius(radius) {}
+ CircleCollider(uint32_t game_object_id, int radius)
+ : Collider(game_object_id), radius(radius) {}
int radius;
};
diff --git a/src/crepe/api/Color.cpp b/src/crepe/api/Color.cpp
index 5c7d8cc..71592da 100644
--- a/src/crepe/api/Color.cpp
+++ b/src/crepe/api/Color.cpp
@@ -1,5 +1,3 @@
-
-
#include "Color.h"
using namespace crepe::api;
diff --git a/src/crepe/api/Force.cpp b/src/crepe/api/Force.cpp
index ff82afa..98649c1 100644
--- a/src/crepe/api/Force.cpp
+++ b/src/crepe/api/Force.cpp
@@ -1,16 +1,17 @@
-#include "Force.h"
#include <cmath>
+#include "Force.h"
+
namespace crepe::api {
-Force::Force(uint32_t gameObjectId, uint32_t forceMagnitude, uint32_t direction)
- : Component(gameObjectId) {
+Force::Force(uint32_t game_object_id, uint32_t magnitude, uint32_t direction)
+ : Component(game_object_id) {
// Convert direction from degrees to radians
float radian_direction = static_cast<float>(direction) * (M_PI / 180.0f);
force_x = static_cast<int32_t>(
- std::round(forceMagnitude * std::cos(radian_direction)));
+ std::round(magnitude * std::cos(radian_direction)));
force_y = static_cast<int32_t>(
- std::round(forceMagnitude * std::sin(radian_direction)));
+ std::round(magnitude * std::sin(radian_direction)));
}
} // namespace crepe::api
diff --git a/src/crepe/api/Force.h b/src/crepe/api/Force.h
index 1d30af4..8da9a00 100644
--- a/src/crepe/api/Force.h
+++ b/src/crepe/api/Force.h
@@ -1,14 +1,14 @@
#pragma once
-#include "../Component.h"
#include <cstdint>
-#include <utility>
+
+#include "../Component.h"
namespace crepe::api {
class Force : public Component {
public:
- Force(uint32_t gameObjectId, uint32_t forceMagnitude, uint32_t direction);
+ Force(uint32_t game_object_id, uint32_t magnitude, uint32_t direction);
int32_t force_x;
int32_t force_y;
diff --git a/src/crepe/api/ParticleEmitter.cpp b/src/crepe/api/ParticleEmitter.cpp
index 298a5ec..2e07562 100644
--- a/src/crepe/api/ParticleEmitter.cpp
+++ b/src/crepe/api/ParticleEmitter.cpp
@@ -1,29 +1,28 @@
-#include "ParticleEmitter.h"
-#include "Particle.h"
#include <ctime>
#include <iostream>
+#include "Particle.h"
+#include "ParticleEmitter.h"
+
using namespace crepe;
-ParticleEmitter::ParticleEmitter(uint32_t gameObjectId, uint32_t max_particles,
- uint32_t emission_rate, uint32_t speed,
- uint32_t speed_offset, uint32_t angle,
- uint32_t angleOffset, float m_begin_lifespan,
- float m_end_lifespan)
- : Component(gameObjectId), m_max_particles(max_particles),
- m_emission_rate(emission_rate), m_speed(speed), m_speed_offset(speed_offset),
- m_position{0, 0}, m_begin_lifespan(m_begin_lifespan),
- m_end_lifespan(m_end_lifespan) {
+ParticleEmitter::ParticleEmitter(uint32_t game_object_id,
+ uint32_t max_particles, uint32_t emission_rate,
+ uint32_t speed, uint32_t speed_offset,
+ uint32_t angle, uint32_t angleOffset,
+ float begin_lifespan, float end_lifespan)
+ : Component(game_object_id), max_particles(max_particles),
+ emission_rate(emission_rate), speed(speed), speed_offset(speed_offset),
+ position{0, 0}, begin_lifespan(begin_lifespan),
+ end_lifespan(end_lifespan) {
std::srand(
static_cast<uint32_t>(std::time(nullptr))); // initialize random seed
std::cout << "Create emitter" << std::endl;
- m_min_angle
- = (360 + angle - (angleOffset % 360)) % 360; // calculate minAngle
- m_max_angle
- = (360 + angle + (angleOffset % 360)) % 360; // calculate maxAngle
- m_position.x = 400;
- m_position.y = 400;
- for (size_t i = 0; i < m_max_particles; i++) {
+ min_angle = (360 + angle - (angleOffset % 360)) % 360; // calculate minAngle
+ max_angle = (360 + angle + (angleOffset % 360)) % 360; // calculate maxAngle
+ position.x = 400;
+ position.y = 400;
+ for (size_t i = 0; i < max_particles; i++) {
this->particles.emplace_back();
}
}
diff --git a/src/crepe/api/ParticleEmitter.h b/src/crepe/api/ParticleEmitter.h
index 23f02f6..2e2e95b 100644
--- a/src/crepe/api/ParticleEmitter.h
+++ b/src/crepe/api/ParticleEmitter.h
@@ -1,32 +1,42 @@
#pragma once
-#include "Component.h"
-#include "Particle.h"
#include <cstdint>
#include <vector>
-#
+
+#include "Component.h"
+#include "Particle.h"
namespace crepe {
class ParticleEmitter : public Component {
public:
- ParticleEmitter(uint32_t gameObjectId, uint32_t maxParticles,
- uint32_t emissionRate, uint32_t speed, uint32_t speedOffset,
- uint32_t angle, uint32_t angleOffset, float m_beginLifespan,
- float m_endLifespan);
+ ParticleEmitter(uint32_t game_object_id, uint32_t max_particles,
+ uint32_t emission_rate, uint32_t speed,
+ uint32_t speed_offset, uint32_t angle, uint32_t angleOffset,
+ float begin_lifespan, float end_lifespan);
~ParticleEmitter();
- Position m_position; //position of the emitter
- uint32_t m_max_particles; //maximum number of particles
- uint32_t m_emission_rate; //rate of particle emission
- uint32_t m_speed; //base speed of the particles
- uint32_t m_speed_offset; //offset for random speed variation
- uint32_t m_min_angle; //min angle of particle emission
- uint32_t m_max_angle; //max angle of particle emission
- float m_begin_lifespan; //begin Lifespan of particle (only visual)
- float m_end_lifespan; //begin Lifespan of particle
+ //! position of the emitter
+ Position position;
+ //! maximum number of particles
+ uint32_t max_particles;
+ //! rate of particle emission
+ uint32_t emission_rate;
+ //! base speed of the particles
+ uint32_t speed;
+ //! offset for random speed variation
+ uint32_t speed_offset;
+ //! min angle of particle emission
+ uint32_t min_angle;
+ //! max angle of particle emission
+ uint32_t max_angle;
+ //! begin Lifespan of particle (only visual)
+ float begin_lifespan;
+ //! begin Lifespan of particle
+ float end_lifespan;
- std::vector<Particle> particles; //collection of particles
+ //! collection of particles
+ std::vector<Particle> particles;
};
} // namespace crepe
diff --git a/src/crepe/api/Rigidbody.cpp b/src/crepe/api/Rigidbody.cpp
index b35d5b8..ebf9fb9 100644
--- a/src/crepe/api/Rigidbody.cpp
+++ b/src/crepe/api/Rigidbody.cpp
@@ -2,7 +2,7 @@
using namespace crepe::api;
-Rigidbody::Rigidbody(uint32_t gameObjectId, int mass, int gravityScale,
+Rigidbody::Rigidbody(uint32_t game_object_id, int mass, int gravity_scale,
BodyType bodyType)
- : Component(gameObjectId), mass(mass), gravity_scale(gravityScale),
+ : Component(game_object_id), mass(mass), gravity_scale(gravity_scale),
body_type(bodyType) {}
diff --git a/src/crepe/api/Rigidbody.h b/src/crepe/api/Rigidbody.h
index dc242c1..05cbb03 100644
--- a/src/crepe/api/Rigidbody.h
+++ b/src/crepe/api/Rigidbody.h
@@ -1,20 +1,24 @@
#pragma once
-#include "../Component.h"
#include <cstdint>
+#include "../Component.h"
+
namespace crepe::api {
enum class BodyType {
- STATIC, // Does not move (e.g. walls, ground ...)
- DYNAMIC, // Moves and responds to forces (e.g. player, physics objects ...)
- KINEMATIC // Moves but does not respond to forces (e.g. moving platforms ...)
+ //! Does not move (e.g. walls, ground ...)
+ STATIC,
+ //! Moves and responds to forces (e.g. player, physics objects ...)
+ DYNAMIC,
+ //! Moves but does not respond to forces (e.g. moving platforms ...)
+ KINEMATIC,
};
class Rigidbody : public Component {
public:
- Rigidbody(uint32_t gameObjectId, int mass, int gravityScale,
- BodyType bodyType);
+ Rigidbody(uint32_t game_object_id, int mass, int gravity_scale,
+ BodyType body_type);
int32_t velocity_x;
int32_t velocity_y;
int mass;
diff --git a/src/crepe/api/Sprite.cpp b/src/crepe/api/Sprite.cpp
index cdece28..806f147 100644
--- a/src/crepe/api/Sprite.cpp
+++ b/src/crepe/api/Sprite.cpp
@@ -1,12 +1,11 @@
+#include <cstdint>
+#include <memory>
-
-#include "Sprite.h"
-#include "Component.h"
#include "api/Texture.h"
#include "util/log.h"
-#include <cstdint>
-#include <memory>
-#include <utility>
+
+#include "Component.h"
+#include "Sprite.h"
using namespace std;
using namespace crepe;
diff --git a/src/crepe/api/Sprite.h b/src/crepe/api/Sprite.h
index 7a701e3..b06125e 100644
--- a/src/crepe/api/Sprite.h
+++ b/src/crepe/api/Sprite.h
@@ -1,18 +1,21 @@
#pragma once
-#include "Component.h"
-#include "api/Color.h"
-#include "api/Texture.h"
#include <SDL2/SDL_rect.h>
#include <cstdint>
#include <memory>
+#include "api/Color.h"
+#include "api/Texture.h"
+
+#include "Component.h"
+
namespace crepe::api {
struct FlipSettings {
bool flip_x = 1;
bool flip_y = 1;
};
+
class Sprite : public Component {
public:
diff --git a/src/crepe/api/Texture.cpp b/src/crepe/api/Texture.cpp
index c755fa9..7791b5b 100644
--- a/src/crepe/api/Texture.cpp
+++ b/src/crepe/api/Texture.cpp
@@ -1,31 +1,32 @@
+#include <SDL2/SDL_render.h>
+#include "util/log.h"
#include "Asset.h"
#include "SdlContext.h"
-#include "util/log.h"
-
#include "Texture.h"
-#include <SDL2/SDL_render.h>
using namespace crepe::api;
+using namespace std;
-Texture::Texture(std::unique_ptr<Asset> res) {
+Texture::Texture(unique_ptr<Asset> res) {
dbg_trace();
this->load(std::move(res));
}
Texture::Texture(const char * src) {
dbg_trace();
- this->load(std::make_unique<Asset>(src));
+ this->load(make_unique<Asset>(src));
}
Texture::~Texture() {
dbg_trace();
- if (this->m_texture != nullptr) {
- SDL_DestroyTexture(m_texture);
+ if (this->texture != nullptr) {
+ SDL_DestroyTexture(this->texture);
}
}
-void Texture::load(std::unique_ptr<Asset> res) {
+
+void Texture::load(unique_ptr<Asset> res) {
SdlContext & ctx = SdlContext::get_instance();
- m_texture = ctx.texture_from_path(res->canonical());
+ this->texture = ctx.texture_from_path(res->canonical());
}
diff --git a/src/crepe/api/Texture.h b/src/crepe/api/Texture.h
index 6d3fb40..993f72b 100644
--- a/src/crepe/api/Texture.h
+++ b/src/crepe/api/Texture.h
@@ -1,9 +1,10 @@
#pragma once
-#include "Asset.h"
#include <SDL2/SDL_render.h>
#include <memory>
+#include "Asset.h"
+
namespace crepe {
class SdlContext;
}
@@ -21,7 +22,7 @@ private:
void load(std::unique_ptr<Asset> res);
private:
- SDL_Texture * m_texture = nullptr;
+ SDL_Texture * texture = nullptr;
friend class crepe::SdlContext;
};
diff --git a/src/crepe/api/Transform.cpp b/src/crepe/api/Transform.cpp
index 4f22843..626cd67 100644
--- a/src/crepe/api/Transform.cpp
+++ b/src/crepe/api/Transform.cpp
@@ -1,10 +1,10 @@
+#include <cstdint>
-
-#include "Transform.h"
-#include "Component.h"
#include "api/Point.h"
#include "util/log.h"
-#include <cstdint>
+
+#include "Component.h"
+#include "Transform.h"
using namespace crepe::api;
diff --git a/src/crepe/api/Transform.h b/src/crepe/api/Transform.h
index c9d46c5..7b74e43 100644
--- a/src/crepe/api/Transform.h
+++ b/src/crepe/api/Transform.h
@@ -1,11 +1,15 @@
#pragma once
-#include "Component.h"
-#include "api/Point.h"
#include <cstdint>
+
+#include "api/Point.h"
+
+#include "Component.h"
+
namespace crepe::api {
class Transform : public Component {
+
public:
Transform(uint32_t id, Point &, double, double);
~Transform();
@@ -13,4 +17,5 @@ public:
double rotation; // Rotation, in radians
double scale; // Multiplication factoh
};
+
} // namespace crepe::api