aboutsummaryrefslogtreecommitdiff
path: root/src/crepe
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe')
-rw-r--r--src/crepe/CMakeLists.txt15
-rw-r--r--src/crepe/CircleCollider.h12
-rw-r--r--src/crepe/CollisionSystem.cpp13
-rw-r--r--src/crepe/CollisionSystem.h15
-rw-r--r--src/crepe/Component.cpp2
-rw-r--r--src/crepe/Component.h12
-rw-r--r--src/crepe/ComponentManager.hpp2
-rw-r--r--src/crepe/Force.cpp14
-rw-r--r--src/crepe/Force.h17
-rw-r--r--src/crepe/Particle.cpp25
-rw-r--r--src/crepe/Particle.h24
-rw-r--r--src/crepe/ParticleEmitter.cpp28
-rw-r--r--src/crepe/ParticleEmitter.h32
-rw-r--r--src/crepe/ParticleSystem.cpp59
-rw-r--r--src/crepe/ParticleSystem.h19
-rw-r--r--src/crepe/PhysicsSystem.cpp55
-rw-r--r--src/crepe/PhysicsSystem.h17
-rw-r--r--src/crepe/SDLApp.cpp78
-rw-r--r--src/crepe/SDLApp.h28
-rw-r--r--src/crepe/Transform.cpp6
-rw-r--r--src/crepe/Transform.h22
-rw-r--r--src/crepe/api/BehaviorScript.cpp2
-rw-r--r--src/crepe/api/Collider.cpp2
-rw-r--r--src/crepe/api/Collider.h2
-rw-r--r--src/crepe/api/Rigidbody.cpp5
-rw-r--r--src/crepe/api/Rigidbody.h18
-rw-r--r--src/crepe/crepe/CMakeFiles/CMakeDirectoryInformation.cmake16
-rw-r--r--src/crepe/crepe/CMakeFiles/progress.marks1
-rw-r--r--src/crepe/crepe/Makefile140
-rw-r--r--src/crepe/crepe/cmake_install.cmake44
-rw-r--r--src/crepe/util/log.h2
31 files changed, 711 insertions, 16 deletions
diff --git a/src/crepe/CMakeLists.txt b/src/crepe/CMakeLists.txt
index cc20f83..497423e 100644
--- a/src/crepe/CMakeLists.txt
+++ b/src/crepe/CMakeLists.txt
@@ -1,24 +1,39 @@
+
target_sources(crepe PUBLIC
Asset.cpp
Sound.cpp
SoundContext.cpp
+ Particle.cpp
+ ParticleEmitter.cpp
+ ParticleSystem.cpp
SdlContext.cpp
ComponentManager.cpp
Component.cpp
ScriptSystem.cpp
RenderSystem.cpp
+ PhysicsSystem.cpp
+ Transform.cpp
+ Force.cpp
+ CollisionSystem.cpp
)
target_sources(crepe PUBLIC FILE_SET HEADERS FILES
Asset.h
Sound.h
SoundContext.h
+ ParticleEmitter.h
+ ParticleSystem.h
+ Particle.h
SdlContext.h
ComponentManager.h
ComponentManager.hpp
Component.h
System.h
ScriptSystem.h
+ PhysicsSystem.h
+ Transform.h
+ Force.h
+ CollisionSystem.h
RenderSystem.h
)
diff --git a/src/crepe/CircleCollider.h b/src/crepe/CircleCollider.h
new file mode 100644
index 0000000..922477b
--- /dev/null
+++ b/src/crepe/CircleCollider.h
@@ -0,0 +1,12 @@
+#pragma once
+#include "Collider.h"
+
+namespace crepe {
+
+class CircleCollider : public Collider {
+public:
+ CircleCollider(uint32_t gameObjectId,int radius) : Collider(gameObjectId), radius(radius) {}
+ int radius;
+};
+
+} // namespace crepe
diff --git a/src/crepe/CollisionSystem.cpp b/src/crepe/CollisionSystem.cpp
new file mode 100644
index 0000000..a0c6dca
--- /dev/null
+++ b/src/crepe/CollisionSystem.cpp
@@ -0,0 +1,13 @@
+#include "CollisionSystem.h"
+#include "ComponentManager.h"
+#include <iostream>
+
+using namespace crepe;
+
+CollisionSystem::CollisionSystem() {
+
+}
+
+void CollisionSystem::update() {
+
+}
diff --git a/src/crepe/CollisionSystem.h b/src/crepe/CollisionSystem.h
new file mode 100644
index 0000000..70d7237
--- /dev/null
+++ b/src/crepe/CollisionSystem.h
@@ -0,0 +1,15 @@
+#pragma once
+
+namespace crepe {
+
+class CollisionSystem
+{
+ private:
+ /* data */
+ public:
+ CollisionSystem(/* args */);
+ void update();
+};
+
+}
+
diff --git a/src/crepe/Component.cpp b/src/crepe/Component.cpp
index bce90f1..e2cd7e0 100644
--- a/src/crepe/Component.cpp
+++ b/src/crepe/Component.cpp
@@ -1,3 +1,5 @@
#include "Component.h"
using namespace crepe;
+
+Component::Component(uint32_t id) : gameObjectId(id), active(true) {}
diff --git a/src/crepe/Component.h b/src/crepe/Component.h
index 9cda177..8a42a45 100644
--- a/src/crepe/Component.h
+++ b/src/crepe/Component.h
@@ -1,4 +1,5 @@
#pragma once
+#include <cstdint>
namespace crepe {
@@ -7,10 +8,13 @@ protected:
Component() = default;
public:
- virtual ~Component() = default;
-
-public:
- bool active = true;
+ Component(uint32_t id);
+ virtual ~Component() {}
+ // TODO: shouldn't this constructor be deleted because this class will never
+ // directly be instantiated?
+ //changed so it sets the id (jaro)
+ uint32_t gameObjectId;
+ bool active;
};
} // namespace crepe
diff --git a/src/crepe/ComponentManager.hpp b/src/crepe/ComponentManager.hpp
index 2377a94..22dbc66 100644
--- a/src/crepe/ComponentManager.hpp
+++ b/src/crepe/ComponentManager.hpp
@@ -30,7 +30,7 @@ T & ComponentManager::add_component(uint32_t id, Args &&... args) {
// Create a new component of type T (arguments directly forwarded). The
// constructor must be called by ComponentManager.
- T * instance = new T(forward<Args>(args)...);
+ T * instance = new T(id,forward<Args>(args)...);
// store its unique_ptr in the vector<>
components[type][id].push_back(unique_ptr<T>(instance));
diff --git a/src/crepe/Force.cpp b/src/crepe/Force.cpp
new file mode 100644
index 0000000..b314f49
--- /dev/null
+++ b/src/crepe/Force.cpp
@@ -0,0 +1,14 @@
+#include "Force.h"
+#include <cmath>
+
+namespace crepe {
+
+Force::Force(uint32_t gameObjectId, uint32_t forceMagnitude, uint32_t direction): Component(gameObjectId)
+{
+ // 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)));
+ force_y = static_cast<int32_t>(std::round(forceMagnitude * std::sin(radian_direction)));
+}
+
+} // namespace crepe
diff --git a/src/crepe/Force.h b/src/crepe/Force.h
new file mode 100644
index 0000000..a121ec2
--- /dev/null
+++ b/src/crepe/Force.h
@@ -0,0 +1,17 @@
+#pragma once
+
+#include "Component.h"
+#include <cstdint>
+#include <utility>
+
+namespace crepe {
+
+class Force : public Component {
+public:
+ Force(uint32_t gameObjectId, uint32_t forceMagnitude, uint32_t direction);
+
+ int32_t force_x;
+ int32_t force_y;
+};
+
+} // namespace crepe
diff --git a/src/crepe/Particle.cpp b/src/crepe/Particle.cpp
new file mode 100644
index 0000000..aa33606
--- /dev/null
+++ b/src/crepe/Particle.cpp
@@ -0,0 +1,25 @@
+#include "Particle.h"
+#include <iostream>
+
+using namespace crepe;
+
+Particle::Particle()
+{
+ this->active = false;
+}
+
+void Particle::reset(float lifespan, Position position, Position velocity) {
+ this->timeInLife = 0;
+ this->lifespan = lifespan;
+ this->position = position;
+ this->velocity = velocity;
+ this->active = true;
+}
+
+void Particle::update(float deltaTime) {
+ timeInLife += deltaTime;
+ position.x += velocity.x * deltaTime;
+ position.y += velocity.y * deltaTime;
+ if(timeInLife >= lifespan)this->active = false;
+}
+
diff --git a/src/crepe/Particle.h b/src/crepe/Particle.h
new file mode 100644
index 0000000..c408ed9
--- /dev/null
+++ b/src/crepe/Particle.h
@@ -0,0 +1,24 @@
+#pragma once
+
+namespace crepe {
+
+struct Position {
+ float x;
+ float y;
+ };
+
+class Particle {
+public:
+
+ Position position;
+ Position velocity;
+ float lifespan;
+ bool active;
+
+ Particle();
+ void reset(float lifespan, Position position, Position velocity);
+ void update(float deltaTime);
+ float timeInLife;
+};
+
+}
diff --git a/src/crepe/ParticleEmitter.cpp b/src/crepe/ParticleEmitter.cpp
new file mode 100644
index 0000000..318c6db
--- /dev/null
+++ b/src/crepe/ParticleEmitter.cpp
@@ -0,0 +1,28 @@
+#include "ParticleEmitter.h"
+#include <ctime>
+#include "Particle.h"
+#include <iostream>
+
+using namespace crepe;
+
+ParticleEmitter::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)
+ : Component(gameObjectId), m_maxParticles(maxParticles), m_emissionRate(emissionRate), m_speed(speed), m_speedOffset(speedOffset), m_position{0, 0}, m_beginLifespan(m_beginLifespan),m_endLifespan(m_endLifespan) {
+ std::srand(static_cast<uint32_t>(std::time(nullptr))); // initialize random seed
+ std::cout << "Create emitter" << std::endl;
+ m_minAngle = (360 + angle - (angleOffset % 360)) % 360; // calculate minAngle
+ m_maxAngle = (360 + angle + (angleOffset % 360)) % 360; // calculate maxAngle
+ m_position.x = 400;
+ m_position.y = 400;
+ for (size_t i = 0; i < m_maxParticles; i++)
+ {
+ this->particles.emplace_back();
+ }
+
+}
+
+ParticleEmitter::~ParticleEmitter() {
+ std::vector<Particle>::iterator it = this->particles.begin();
+ while (it != this->particles.end()) {
+ it = this->particles.erase(it);
+ }
+}
diff --git a/src/crepe/ParticleEmitter.h b/src/crepe/ParticleEmitter.h
new file mode 100644
index 0000000..8cd78a9
--- /dev/null
+++ b/src/crepe/ParticleEmitter.h
@@ -0,0 +1,32 @@
+#pragma once
+
+#include <vector>
+#include "Particle.h"
+#include <cstdint>
+#include "Component.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();
+
+ Position m_position; //position of the emitter
+ uint32_t m_maxParticles; //maximum number of particles
+ uint32_t m_emissionRate; //rate of particle emission
+ uint32_t m_speed; //base speed of the particles
+ uint32_t m_speedOffset; //offset for random speed variation
+ uint32_t m_minAngle; //min angle of particle emission
+ uint32_t m_maxAngle; //max angle of particle emission
+ float m_beginLifespan; //begin Lifespan of particle (only visual)
+ float m_endLifespan; //begin Lifespan of particle
+
+ std::vector<Particle> particles; //collection of particles
+
+};
+
+}
+
+
diff --git a/src/crepe/ParticleSystem.cpp b/src/crepe/ParticleSystem.cpp
new file mode 100644
index 0000000..0dad4cd
--- /dev/null
+++ b/src/crepe/ParticleSystem.cpp
@@ -0,0 +1,59 @@
+#include "ParticleSystem.h"
+#include <cmath>
+#include <ctime>
+#include "ParticleEmitter.h"
+#include "Particle.h"
+#include "ComponentManager.h"
+
+using namespace crepe;
+
+ParticleSystem::ParticleSystem() : m_elapsedTime(0.0f) {} // Initialize m_elapsedTime to 0
+
+void ParticleSystem::update() {
+ ComponentManager& mgr = ComponentManager::get_instance();
+ std::vector<std::reference_wrapper<ParticleEmitter>> emitters = mgr.get_components_by_type<ParticleEmitter>();
+ float deltaTime = 0.10;
+ for (ParticleEmitter& emitter : emitters) {
+ float updateAmount = 1/static_cast<float>(emitter.m_emissionRate);
+ for (float i = 0; i < deltaTime; i += updateAmount)
+ {
+ emitParticle(emitter);
+ }
+ for (size_t j = 0; j < emitter.particles.size(); j++)
+ {
+ if(emitter.particles[j].active)
+ {
+ emitter.particles[j].update(deltaTime);
+ }
+ }
+ }
+}
+
+void ParticleSystem::emitParticle(ParticleEmitter& emitter) {
+ Position initialPosition = { emitter.m_position.x, emitter.m_position.y};
+ float randomAngle = 0.0f;
+ if(emitter.m_maxAngle < emitter.m_minAngle)
+ {
+ randomAngle = ((emitter.m_minAngle + (std::rand() % (static_cast<uint32_t>(emitter.m_maxAngle + 360 - emitter.m_minAngle + 1))))%360);
+ }
+ else
+ {
+ randomAngle = emitter.m_minAngle + (std::rand() % (static_cast<uint32_t>(emitter.m_maxAngle - emitter.m_minAngle + 1)));
+ }
+ float angleInRadians = randomAngle * (M_PI / 180.0f);
+ float randomSpeedOffset = (static_cast<float>(std::rand()) / RAND_MAX) * (2 * emitter.m_speedOffset) - emitter.m_speedOffset;
+ float velocityX = (emitter.m_speed + randomSpeedOffset) * std::cos(angleInRadians);
+ float velocityY = (emitter.m_speed + randomSpeedOffset) * std::sin(angleInRadians);
+ Position initialVelocity = {
+ velocityX,
+ velocityY
+ };
+ for (size_t i = 0; i < emitter.particles.size(); i++)
+ {
+ if(!emitter.particles[i].active)
+ {
+ emitter.particles[i].reset(emitter.m_endLifespan, initialPosition, initialVelocity);
+ break;
+ }
+ }
+}
diff --git a/src/crepe/ParticleSystem.h b/src/crepe/ParticleSystem.h
new file mode 100644
index 0000000..c8777f5
--- /dev/null
+++ b/src/crepe/ParticleSystem.h
@@ -0,0 +1,19 @@
+#pragma once
+
+#include <vector>
+#include "ParticleEmitter.h"
+
+
+namespace crepe {
+
+class ParticleSystem {
+public:
+ ParticleSystem();
+ void update();
+private:
+ void emitParticle(ParticleEmitter &emitter); //emits a new particle
+
+ float m_elapsedTime; //elapsed time since the last emission
+};
+
+}
diff --git a/src/crepe/PhysicsSystem.cpp b/src/crepe/PhysicsSystem.cpp
new file mode 100644
index 0000000..7d16044
--- /dev/null
+++ b/src/crepe/PhysicsSystem.cpp
@@ -0,0 +1,55 @@
+#include "PhysicsSystem.h"
+#include "ComponentManager.h"
+#include "Rigidbody.h"
+#include "Transform.h"
+#include "Force.h"
+#include <iostream>
+
+using namespace crepe;
+
+PhysicsSystem::PhysicsSystem() {
+
+}
+
+void PhysicsSystem::update() {
+ ComponentManager& mgr = ComponentManager::get_instance();
+ std::vector<std::reference_wrapper<Rigidbody>> rigidbodies = mgr.get_components_by_type<Rigidbody>();
+ std::vector<std::reference_wrapper<Transform>> transforms = mgr.get_components_by_type<Transform>();
+
+ for (Rigidbody& rigidbody : rigidbodies) {
+
+ switch (rigidbody.body_type)
+ {
+ case BodyType::Dynamic :
+ for (Transform& transform : transforms) {
+ if(transform.gameObjectId == rigidbody.gameObjectId)
+ {
+ rigidbody.velocity_x = 0;
+ rigidbody.velocity_y = 0;
+ std::vector<std::reference_wrapper<Force>> Forces = mgr.get_components_by_id<Force>(rigidbody.gameObjectId);
+ rigidbody.velocity_y += rigidbody.gravity_scale * 1 * rigidbody.mass;
+
+ for (Force& force : Forces)
+ {
+ rigidbody.velocity_x += force.force_x;
+ rigidbody.velocity_y += force.force_y;
+ }
+
+ std::cout << "before transform.postion.x " << transform.postion.x << std::endl;
+ std::cout << "before transform.postion.y " << transform.postion.y << std::endl;
+ transform.postion.x += rigidbody.velocity_x;
+ transform.postion.y += rigidbody.velocity_y;
+ std::cout << "after transform.postion.x " << transform.postion.x << std::endl;
+ std::cout << "after transform.postion.y " << transform.postion.y << std::endl;
+ }
+ }
+ break;
+ case BodyType::Kinematic :
+ break; //(scripts)
+ case BodyType::Static :
+ break; //(unmoveable objects)
+ default:
+ break;
+ }
+ }
+}
diff --git a/src/crepe/PhysicsSystem.h b/src/crepe/PhysicsSystem.h
new file mode 100644
index 0000000..1899089
--- /dev/null
+++ b/src/crepe/PhysicsSystem.h
@@ -0,0 +1,17 @@
+#pragma once
+
+namespace crepe {
+
+class PhysicsSystem
+{
+ private:
+ /* data */
+ public:
+ PhysicsSystem(/* args */);
+ void update();
+};
+
+}
+
+
+
diff --git a/src/crepe/SDLApp.cpp b/src/crepe/SDLApp.cpp
new file mode 100644
index 0000000..715dd6f
--- /dev/null
+++ b/src/crepe/SDLApp.cpp
@@ -0,0 +1,78 @@
+#include "SDLApp.h"
+#include <iostream>
+#include <vector>
+#include "Particle.h"
+#include "ParticleEmitter.h"
+
+SDLApp::SDLApp(int windowWidth, int windowHeight)
+ : windowWidth(windowWidth), windowHeight(windowHeight), window(nullptr), renderer(nullptr) {}
+
+SDLApp::~SDLApp() {
+ cleanUp();
+}
+
+bool SDLApp::initialize() {
+ if (SDL_Init(SDL_INIT_VIDEO) != 0) {
+ std::cerr << "SDL Initialization Error: " << SDL_GetError() << std::endl;
+ return false;
+ }
+
+ window = SDL_CreateWindow("Particle System",
+ SDL_WINDOWPOS_CENTERED,
+ SDL_WINDOWPOS_CENTERED,
+ windowWidth,
+ windowHeight,
+ SDL_WINDOW_SHOWN);
+ if (!window) {
+ std::cerr << "Window Creation Error: " << SDL_GetError() << std::endl;
+ return false;
+ }
+
+ renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
+ if (!renderer) {
+ std::cerr << "Renderer Creation Error: " << SDL_GetError() << std::endl;
+ return false;
+ }
+
+ return true;
+}
+
+void SDLApp::handleEvents(bool& running) {
+ SDL_Event event;
+ while (SDL_PollEvent(&event)) {
+ if (event.type == SDL_QUIT) {
+ running = false;
+ }
+ }
+}
+
+void SDLApp::clearScreen() {
+ SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
+ SDL_RenderClear(renderer);
+}
+
+void SDLApp::presentScreen() {
+ SDL_RenderPresent(renderer);
+}
+
+void SDLApp::drawSquare(int x, int y, int size) {
+ SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
+ SDL_Rect rect = { x, y, size, size };
+ SDL_RenderFillRect(renderer, &rect);
+}
+
+SDL_Texture* squareTexture = nullptr; // Load this with an image or create it
+
+
+
+
+
+void SDLApp::cleanUp() {
+ if (renderer) {
+ SDL_DestroyRenderer(renderer);
+ }
+ if (window) {
+ SDL_DestroyWindow(window);
+ }
+ SDL_Quit();
+}
diff --git a/src/crepe/SDLApp.h b/src/crepe/SDLApp.h
new file mode 100644
index 0000000..8915d30
--- /dev/null
+++ b/src/crepe/SDLApp.h
@@ -0,0 +1,28 @@
+#ifndef SDLAPP_HPP
+#define SDLAPP_HPP
+
+#include <SDL2/SDL.h>
+#include "Particle.h"
+#include "ParticleEmitter.h"
+
+class SDLApp {
+public:
+ SDLApp(int windowWidth, int windowHeight);
+ ~SDLApp();
+
+ bool initialize();
+ void handleEvents(bool& running);
+ void clearScreen();
+ void presentScreen();
+ void drawSquare(int x, int y, int size);
+ void cleanUp();
+ void drawParticles(const std::vector<crepe::ParticleEmitter>& emitters);
+ void drawMultipleSquares(const std::vector<SDL_Rect>& squares);
+private:
+ int windowWidth;
+ int windowHeight;
+ SDL_Window* window;
+ SDL_Renderer* renderer;
+};
+
+#endif
diff --git a/src/crepe/Transform.cpp b/src/crepe/Transform.cpp
new file mode 100644
index 0000000..2c39523
--- /dev/null
+++ b/src/crepe/Transform.cpp
@@ -0,0 +1,6 @@
+#include "Transform.h"
+
+using namespace crepe;
+
+Transform::Transform(uint32_t gameObjectId,Position position, int rotation, int scale)
+ : Component(gameObjectId), postion(postion), rotation(rotation), scale(scale) {}
diff --git a/src/crepe/Transform.h b/src/crepe/Transform.h
new file mode 100644
index 0000000..3e8d142
--- /dev/null
+++ b/src/crepe/Transform.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "Component.h"
+
+namespace crepe {
+
+struct Position
+{
+ int x;
+ int y;
+};
+
+
+class Transform : public Component {
+public:
+ Transform(uint32_t gameObjectId,Position position, int rotation, int scale);
+ Position postion;
+ int rotation;
+ int scale;
+};
+
+} // namespace crepe
diff --git a/src/crepe/api/BehaviorScript.cpp b/src/crepe/api/BehaviorScript.cpp
index 84bfd4c..74788ec 100644
--- a/src/crepe/api/BehaviorScript.cpp
+++ b/src/crepe/api/BehaviorScript.cpp
@@ -4,4 +4,4 @@
using namespace crepe::api;
-BehaviorScript::BehaviorScript() { dbg_trace(); }
+BehaviorScript::BehaviorScript() : Component(gameObjectId) { dbg_trace(); }
diff --git a/src/crepe/api/Collider.cpp b/src/crepe/api/Collider.cpp
index 6370a42..c3e4929 100644
--- a/src/crepe/api/Collider.cpp
+++ b/src/crepe/api/Collider.cpp
@@ -2,4 +2,4 @@
using namespace crepe::api;
-Collider::Collider(int size) : size(size) {}
+Collider::Collider(uint32_t gameObjectId) : Component(gameObjectId){}
diff --git a/src/crepe/api/Collider.h b/src/crepe/api/Collider.h
index 72d8e77..1d540de 100644
--- a/src/crepe/api/Collider.h
+++ b/src/crepe/api/Collider.h
@@ -6,7 +6,7 @@ namespace crepe::api {
class Collider : public Component {
public:
- Collider(int size);
+ Collider(uint32_t gameObjectId);
int size;
};
diff --git a/src/crepe/api/Rigidbody.cpp b/src/crepe/api/Rigidbody.cpp
index 98d1d60..30a2cff 100644
--- a/src/crepe/api/Rigidbody.cpp
+++ b/src/crepe/api/Rigidbody.cpp
@@ -2,5 +2,6 @@
using namespace crepe::api;
-Rigidbody::Rigidbody(int mass, int gravityScale, int bodyType)
- : mass(mass), gravity_scale(gravityScale), body_type(bodyType) {}
+Rigidbody::Rigidbody(uint32_t gameObjectId,int mass, int gravityScale, BodyType bodyType)
+ : Component(gameObjectId), mass(mass), gravity_scale(gravityScale), body_type(bodyType) {}
+
diff --git a/src/crepe/api/Rigidbody.h b/src/crepe/api/Rigidbody.h
index 6cae579..548650a 100644
--- a/src/crepe/api/Rigidbody.h
+++ b/src/crepe/api/Rigidbody.h
@@ -1,16 +1,24 @@
#pragma once
-#include "../Component.h"
+#include "Component.h"
+#include <cstdint>
-namespace crepe::api {
+namespace crepe {
+
+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 ...)
+};
class Rigidbody : public Component {
public:
- Rigidbody(int mass, int gravityScale, int bodyType);
-
+ Rigidbody(uint32_t gameObjectId,int mass, int gravityScale, BodyType bodyType);
+ int32_t velocity_x;
+ int32_t velocity_y;
int mass;
int gravity_scale;
- int body_type;
+ BodyType body_type;
};
} // namespace crepe::api
diff --git a/src/crepe/crepe/CMakeFiles/CMakeDirectoryInformation.cmake b/src/crepe/crepe/CMakeFiles/CMakeDirectoryInformation.cmake
new file mode 100644
index 0000000..8d03506
--- /dev/null
+++ b/src/crepe/crepe/CMakeFiles/CMakeDirectoryInformation.cmake
@@ -0,0 +1,16 @@
+# CMAKE generated file: DO NOT EDIT!
+# Generated by "Unix Makefiles" Generator, CMake Version 3.28
+
+# Relative path conversion top directories.
+set(CMAKE_RELATIVE_PATH_TOP_SOURCE "/home/jaro/crepe/src")
+set(CMAKE_RELATIVE_PATH_TOP_BINARY "/home/jaro/crepe/src/crepe")
+
+# Force unix paths in dependencies.
+set(CMAKE_FORCE_UNIX_PATHS 1)
+
+
+# The C and CXX include file regular expressions for this directory.
+set(CMAKE_C_INCLUDE_REGEX_SCAN "^.*$")
+set(CMAKE_C_INCLUDE_REGEX_COMPLAIN "^$")
+set(CMAKE_CXX_INCLUDE_REGEX_SCAN ${CMAKE_C_INCLUDE_REGEX_SCAN})
+set(CMAKE_CXX_INCLUDE_REGEX_COMPLAIN ${CMAKE_C_INCLUDE_REGEX_COMPLAIN})
diff --git a/src/crepe/crepe/CMakeFiles/progress.marks b/src/crepe/crepe/CMakeFiles/progress.marks
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/src/crepe/crepe/CMakeFiles/progress.marks
@@ -0,0 +1 @@
+0
diff --git a/src/crepe/crepe/Makefile b/src/crepe/crepe/Makefile
new file mode 100644
index 0000000..094215a
--- /dev/null
+++ b/src/crepe/crepe/Makefile
@@ -0,0 +1,140 @@
+# CMAKE generated file: DO NOT EDIT!
+# Generated by "Unix Makefiles" Generator, CMake Version 3.28
+
+# Default target executed when no arguments are given to make.
+default_target: all
+.PHONY : default_target
+
+# Allow only one "make -f Makefile2" at a time, but pass parallelism.
+.NOTPARALLEL:
+
+#=============================================================================
+# Special targets provided by cmake.
+
+# Disable implicit rules so canonical targets will work.
+.SUFFIXES:
+
+# Disable VCS-based implicit rules.
+% : %,v
+
+# Disable VCS-based implicit rules.
+% : RCS/%
+
+# Disable VCS-based implicit rules.
+% : RCS/%,v
+
+# Disable VCS-based implicit rules.
+% : SCCS/s.%
+
+# Disable VCS-based implicit rules.
+% : s.%
+
+.SUFFIXES: .hpux_make_needs_suffix_list
+
+# Command-line flag to silence nested $(MAKE).
+$(VERBOSE)MAKESILENT = -s
+
+#Suppress display of executed commands.
+$(VERBOSE).SILENT:
+
+# A target that is always out of date.
+cmake_force:
+.PHONY : cmake_force
+
+#=============================================================================
+# Set environment variables for the build.
+
+# The shell in which to execute make rules.
+SHELL = /bin/sh
+
+# The CMake executable.
+CMAKE_COMMAND = /usr/bin/cmake
+
+# The command to remove a file.
+RM = /usr/bin/cmake -E rm -f
+
+# Escaping for special characters.
+EQUALS = =
+
+# The top-level source directory on which CMake was run.
+CMAKE_SOURCE_DIR = /home/jaro/crepe/src
+
+# The top-level build directory on which CMake was run.
+CMAKE_BINARY_DIR = /home/jaro/crepe/src/crepe
+
+#=============================================================================
+# Targets provided globally by CMake.
+
+# Special rule for the target edit_cache
+edit_cache:
+ @$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "No interactive CMake dialog available..."
+ /usr/bin/cmake -E echo No\ interactive\ CMake\ dialog\ available.
+.PHONY : edit_cache
+
+# Special rule for the target edit_cache
+edit_cache/fast: edit_cache
+.PHONY : edit_cache/fast
+
+# Special rule for the target rebuild_cache
+rebuild_cache:
+ @$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Running CMake to regenerate build system..."
+ /usr/bin/cmake --regenerate-during-build -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
+.PHONY : rebuild_cache
+
+# Special rule for the target rebuild_cache
+rebuild_cache/fast: rebuild_cache
+.PHONY : rebuild_cache/fast
+
+# The main all target
+all: cmake_check_build_system
+ cd /home/jaro/crepe/src/crepe && $(CMAKE_COMMAND) -E cmake_progress_start /home/jaro/crepe/src/crepe/CMakeFiles /home/jaro/crepe/src/crepe/crepe//CMakeFiles/progress.marks
+ cd /home/jaro/crepe/src/crepe && $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 crepe/all
+ $(CMAKE_COMMAND) -E cmake_progress_start /home/jaro/crepe/src/crepe/CMakeFiles 0
+.PHONY : all
+
+# The main clean target
+clean:
+ cd /home/jaro/crepe/src/crepe && $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 crepe/clean
+.PHONY : clean
+
+# The main clean target
+clean/fast: clean
+.PHONY : clean/fast
+
+# Prepare targets for installation.
+preinstall: all
+ cd /home/jaro/crepe/src/crepe && $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 crepe/preinstall
+.PHONY : preinstall
+
+# Prepare targets for installation.
+preinstall/fast:
+ cd /home/jaro/crepe/src/crepe && $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 crepe/preinstall
+.PHONY : preinstall/fast
+
+# clear depends
+depend:
+ cd /home/jaro/crepe/src/crepe && $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
+.PHONY : depend
+
+# Help Target
+help:
+ @echo "The following are some of the valid targets for this Makefile:"
+ @echo "... all (the default if no target is provided)"
+ @echo "... clean"
+ @echo "... depend"
+ @echo "... edit_cache"
+ @echo "... rebuild_cache"
+.PHONY : help
+
+
+
+#=============================================================================
+# Special targets to cleanup operation of make.
+
+# Special rule to run CMake to check the build system integrity.
+# No rule that depends on this can have commands that come from listfiles
+# because they might be regenerated.
+cmake_check_build_system:
+ cd /home/jaro/crepe/src/crepe && $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
+.PHONY : cmake_check_build_system
+
diff --git a/src/crepe/crepe/cmake_install.cmake b/src/crepe/crepe/cmake_install.cmake
new file mode 100644
index 0000000..cd57803
--- /dev/null
+++ b/src/crepe/crepe/cmake_install.cmake
@@ -0,0 +1,44 @@
+# Install script for directory: /home/jaro/crepe/src/crepe
+
+# Set the install prefix
+if(NOT DEFINED CMAKE_INSTALL_PREFIX)
+ set(CMAKE_INSTALL_PREFIX "/usr/local")
+endif()
+string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
+
+# Set the install configuration name.
+if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
+ if(BUILD_TYPE)
+ string(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
+ CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
+ else()
+ set(CMAKE_INSTALL_CONFIG_NAME "Debug")
+ endif()
+ message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
+endif()
+
+# Set the component getting installed.
+if(NOT CMAKE_INSTALL_COMPONENT)
+ if(COMPONENT)
+ message(STATUS "Install component: \"${COMPONENT}\"")
+ set(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
+ else()
+ set(CMAKE_INSTALL_COMPONENT)
+ endif()
+endif()
+
+# Install shared libraries without execute permission?
+if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)
+ set(CMAKE_INSTALL_SO_NO_EXE "1")
+endif()
+
+# Is this installation the result of a crosscompile?
+if(NOT DEFINED CMAKE_CROSSCOMPILING)
+ set(CMAKE_CROSSCOMPILING "FALSE")
+endif()
+
+# Set default install directory permissions.
+if(NOT DEFINED CMAKE_OBJDUMP)
+ set(CMAKE_OBJDUMP "/usr/bin/objdump")
+endif()
+
diff --git a/src/crepe/util/log.h b/src/crepe/util/log.h
index 3e36f0a..e2776c9 100644
--- a/src/crepe/util/log.h
+++ b/src/crepe/util/log.h
@@ -9,7 +9,7 @@
#define _crepe_logf_here(fmt, ...) \
crepe::util::logf(util::log_level::DEBUG, "%s%s (%s:%d)%s" fmt "\n", \
crepe::util::color::FG_WHITE, __PRETTY_FUNCTION__, \
- __FILE_NAME__, __LINE__, crepe::util::color::RESET, \
+ __FILE__, __LINE__, crepe::util::color::RESET, \
__VA_ARGS__)
// very illegal global function-style macros