aboutsummaryrefslogtreecommitdiff
path: root/src/crepe
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-14 10:23:04 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-14 10:23:04 +0100
commit5e6b80ba9fe18143b994a301ab0ba1ba54072b43 (patch)
tree2784b5bdb49dba729884af5d4fd80dd9e44776d1 /src/crepe
parent767f40a61952892d60d204ecaaffa07e7e396d28 (diff)
Working color, fucked up git merge
Diffstat (limited to 'src/crepe')
-rw-r--r--src/crepe/Particle.cpp4
-rw-r--r--src/crepe/Particle.h7
-rw-r--r--src/crepe/api/AssetManager.h3
-rw-r--r--src/crepe/api/ParticleEmitter.cpp14
-rw-r--r--src/crepe/api/ParticleEmitter.h14
-rw-r--r--src/crepe/facade/SDLContext.cpp2
-rw-r--r--src/crepe/system/ParticleSystem.cpp2
-rw-r--r--src/crepe/system/ParticleSystem.h15
-rw-r--r--src/crepe/system/PhysicsSystem.h10
-rw-r--r--src/crepe/system/RenderSystem.h2
10 files changed, 26 insertions, 47 deletions
diff --git a/src/crepe/Particle.cpp b/src/crepe/Particle.cpp
index ab55f37..582edf4 100644
--- a/src/crepe/Particle.cpp
+++ b/src/crepe/Particle.cpp
@@ -2,8 +2,8 @@
using namespace crepe;
-void Particle::reset(uint32_t lifespan, Vector2 position, Vector2 velocity,
- double angle) {
+void Particle::reset(uint32_t lifespan, const Vector2 & position,
+ const Vector2 & velocity, double angle) {
// Initialize the particle state
this->time_in_life = 0;
this->lifespan = lifespan;
diff --git a/src/crepe/Particle.h b/src/crepe/Particle.h
index 06431bb..3eaebc3 100644
--- a/src/crepe/Particle.h
+++ b/src/crepe/Particle.h
@@ -30,9 +30,8 @@ public:
//! The time the particle has been alive, in milliseconds.
uint32_t time_in_life = 0;
//! The angle at which the particle is oriented or moving.
- double angle;
+ double angle = 0;
- Particle() = default;
/**
* \brief Resets the particle with new properties.
*
@@ -44,8 +43,8 @@ public:
* \param velocity The initial velocity of the particle.
* \param angle The angle of the particle's trajectory or orientation.
*/
- void reset(uint32_t lifespan, Vector2 position, Vector2 velocity,
- double angle);
+ void reset(uint32_t lifespan, const Vector2 & position,
+ const Vector2 & velocity, double angle);
/**
* \brief Updates the particle's state.
*
diff --git a/src/crepe/api/AssetManager.h b/src/crepe/api/AssetManager.h
index dbfaef3..86a9902 100644
--- a/src/crepe/api/AssetManager.h
+++ b/src/crepe/api/AssetManager.h
@@ -56,7 +56,8 @@ public:
* cache.
*/
template <typename T>
- std::shared_ptr<T> cache(const std::string & file_path, bool reload = false);
+ std::shared_ptr<T> cache(const std::string & file_path,
+ bool reload = false);
};
} // namespace crepe
diff --git a/src/crepe/api/ParticleEmitter.cpp b/src/crepe/api/ParticleEmitter.cpp
index e7f298c..35f960d 100644
--- a/src/crepe/api/ParticleEmitter.cpp
+++ b/src/crepe/api/ParticleEmitter.cpp
@@ -1,18 +1,12 @@
#include "ParticleEmitter.h"
-#include "Particle.h"
using namespace crepe;
-ParticleEmitter::ParticleEmitter(uint32_t game_object_id, const Data & data)
- : Component(game_object_id), data(data) {
+ParticleEmitter::ParticleEmitter(game_object_id_t game_object_id,
+ const Data & data)
+ : Component(game_object_id),
+ data(data) {
for (size_t i = 0; i < this->data.max_particles; i++) {
this->data.particles.emplace_back();
}
}
-
-ParticleEmitter::~ParticleEmitter() {
- std::vector<Particle>::iterator it = this->data.particles.begin();
- while (it != this->data.particles.end()) {
- it = this->data.particles.erase(it);
- }
-}
diff --git a/src/crepe/api/ParticleEmitter.h b/src/crepe/api/ParticleEmitter.h
index 83a1588..a9e872f 100644
--- a/src/crepe/api/ParticleEmitter.h
+++ b/src/crepe/api/ParticleEmitter.h
@@ -1,24 +1,21 @@
#pragma once
-#include <cstdint>
#include <vector>
#include "Component.h"
#include "Particle.h"
-#include "Sprite.h"
#include "Vector2.h"
-// class Sprite;
-
namespace crepe {
+class Sprite;
+
/**
* \brief Data holder for particle emission parameters.
*
* The ParticleEmitter class stores configuration data for particle properties,
* defining the characteristics and boundaries of particle emissions.
*/
-
class ParticleEmitter : public Component {
public:
/**
@@ -48,7 +45,7 @@ public:
//! position of the emitter
Vector2 position;
//! maximum number of particles
- const uint32_t max_particles = 0;
+ const unsigned int max_particles = 0;
//! rate of particle emission per update (Lowest value = 0.001 any lower is ignored)
double emission_rate = 0;
//! min speed of the particles
@@ -75,13 +72,10 @@ public:
public:
/**
- * \brief Constructs a ParticleEmitter data holder with specified settings.
- *
* \param game_object_id Identifier for the game object using this emitter.
* \param data Configuration data defining particle properties.
*/
- ParticleEmitter(uint32_t game_object_id, const Data & data);
- ~ParticleEmitter();
+ ParticleEmitter(game_object_id_t game_object_id, const Data & data);
public:
//! Configuration data for particle emission settings.
diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp
index 4bc4cf8..c78a3ca 100644
--- a/src/crepe/facade/SDLContext.cpp
+++ b/src/crepe/facade/SDLContext.cpp
@@ -174,7 +174,7 @@ SDLContext::texture_from_path(const std::string & path) {
SDL_Surface * tmp = IMG_Load(path.c_str());
if (tmp == nullptr) {
- tmp = IMG_Load("../asset/texture/ERROR.png");
+ tmp = IMG_Load("../asset/texture/ERROR.png");
}
std::unique_ptr<SDL_Surface, std::function<void(SDL_Surface *)>>
diff --git a/src/crepe/system/ParticleSystem.cpp b/src/crepe/system/ParticleSystem.cpp
index 4a25b47..e7a3bec 100644
--- a/src/crepe/system/ParticleSystem.cpp
+++ b/src/crepe/system/ParticleSystem.cpp
@@ -11,8 +11,6 @@
using namespace crepe;
-ParticleSystem::ParticleSystem() {}
-
void ParticleSystem::update() {
// Get all emitters
ComponentManager & mgr = ComponentManager::get_instance();
diff --git a/src/crepe/system/ParticleSystem.h b/src/crepe/system/ParticleSystem.h
index 3155df1..d7ca148 100644
--- a/src/crepe/system/ParticleSystem.h
+++ b/src/crepe/system/ParticleSystem.h
@@ -2,23 +2,20 @@
#include <cstdint>
+#include "System.h"
+
namespace crepe {
class ParticleEmitter;
class Transform;
/**
* \brief ParticleSystem class responsible for managing particle emission, updates, and bounds checking.
*/
-class ParticleSystem {
+class ParticleSystem : public System {
public:
/**
- * \brief Default constructor.
- */
- ParticleSystem();
-
- /**
* \brief Updates all particle emitters by emitting particles, updating particle states, and checking bounds.
*/
- void update();
+ void update() override;
private:
/**
@@ -66,9 +63,9 @@ private:
private:
//! Counter to count updates to determine how many times emit_particle is called.
- uint32_t update_count = 0;
+ unsigned int update_count = 0;
//! Determines the lowest amount of emission rate (1000 = 0.001 = 1 particle per 1000 updates).
- static constexpr uint32_t MAX_UPDATE_COUNT = 100;
+ static constexpr unsigned int MAX_UPDATE_COUNT = 100;
};
} // namespace crepe
diff --git a/src/crepe/system/PhysicsSystem.h b/src/crepe/system/PhysicsSystem.h
index cc13b70..038c120 100644
--- a/src/crepe/system/PhysicsSystem.h
+++ b/src/crepe/system/PhysicsSystem.h
@@ -1,5 +1,7 @@
#pragma once
+#include "System.h"
+
namespace crepe {
/**
* \brief System that controls all physics
@@ -7,18 +9,14 @@ namespace crepe {
* This class is a physics system that uses a rigidbody and transform
* to add physics to a game object.
*/
-class PhysicsSystem {
+class PhysicsSystem : public System {
public:
/**
- * Constructor is default
- */
- PhysicsSystem() = default;
- /**
* \brief updates the physics system.
*
* It calculates new velocties and changes the postion in the transform.
*/
- void update();
+ void update() override;
};
} // namespace crepe
diff --git a/src/crepe/system/RenderSystem.h b/src/crepe/system/RenderSystem.h
index feefa09..6529d41 100644
--- a/src/crepe/system/RenderSystem.h
+++ b/src/crepe/system/RenderSystem.h
@@ -61,10 +61,8 @@ private:
/**
- * \todo Include color handling for sprites.
* \todo Add text rendering using SDL_ttf for text components.
* \todo Implement a text component and a button component.
- * \todo Ensure each sprite is checked for active status before rendering.
* \todo Sort all layers by order before rendering.
* \todo Consider adding text input functionality.
*/