From 163c9e3eea437daa8ef6007fbdf2f91470066cbf Mon Sep 17 00:00:00 2001 From: jaroWMR Date: Thu, 10 Oct 2024 07:49:38 +0200 Subject: fix for build --- src/example/CMakeLists.txt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/example/CMakeLists.txt') diff --git a/src/example/CMakeLists.txt b/src/example/CMakeLists.txt index f66e08a..36ceba1 100644 --- a/src/example/CMakeLists.txt +++ b/src/example/CMakeLists.txt @@ -15,7 +15,5 @@ endfunction() add_example(audio_internal) add_example(components_internal) add_example(script) - -add_executable(particel EXCLUDE_FROM_ALL particel.cpp) -target_link_libraries(particel PUBLIC crepe) - +add_example(particel) +target_link_libraries(particel PUBLIC SDL2) -- cgit v1.2.3 From 016070d47f2fff8cfdd49cc0bdf65c14ef922c94 Mon Sep 17 00:00:00 2001 From: jaroWMR Date: Thu, 10 Oct 2024 09:30:49 +0200 Subject: renamed particel to particle and example uses ecs for poc --- src/crepe/ParticleEmitter.cpp | 2 + src/crepe/ParticleSystem.cpp | 27 ++---------- src/crepe/ParticleSystem.h | 2 +- src/example/CMakeLists.txt | 4 +- src/example/particel.cpp | 84 ------------------------------------- src/example/particle.cpp | 97 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 105 insertions(+), 111 deletions(-) delete mode 100644 src/example/particel.cpp create mode 100644 src/example/particle.cpp (limited to 'src/example/CMakeLists.txt') diff --git a/src/crepe/ParticleEmitter.cpp b/src/crepe/ParticleEmitter.cpp index 9ae5e76..30cba7c 100644 --- a/src/crepe/ParticleEmitter.cpp +++ b/src/crepe/ParticleEmitter.cpp @@ -11,6 +11,8 @@ ParticleEmitter::ParticleEmitter(uint32_t maxParticles, uint32_t emissionRate, u 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(); diff --git a/src/crepe/ParticleSystem.cpp b/src/crepe/ParticleSystem.cpp index 8891e2b..3a1f653 100644 --- a/src/crepe/ParticleSystem.cpp +++ b/src/crepe/ParticleSystem.cpp @@ -5,40 +5,32 @@ #include // include iostream for std::cout #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(float deltaTime, std::vector& emitters) { - // std::cout << "ParticleSystem update" << std::endl; +void ParticleSystem::update(float deltaTime, std::vector>& emitters) { for (ParticleEmitter& emitter : emitters) { float updateAmount = 1/static_cast(emitter.m_emissionRate); for (float i = 0; i < deltaTime; i += updateAmount) { emitParticle(emitter); } - // std::cout << "after emit" << std::endl; - - //update/move particles afterwards delete if not alive. for (size_t j = 0; j < emitter.particles.size(); j++) { - // std::cout << "update" << std::endl; if(emitter.particles[j].active) { emitter.particles[j].update(deltaTime); } } - - } } void ParticleSystem::emitParticle(ParticleEmitter& emitter) { - // std::cout << "new emitter:" << std::endl; - Position initialPosition = { emitter.m_position.x, emitter.m_position.y }; + Position initialPosition = { emitter.m_position.x, emitter.m_position.y}; float randomAngle = 0.0f; - //check if value is overthe 360 degrees if(emitter.m_maxAngle < emitter.m_minAngle) { randomAngle = ((emitter.m_minAngle + (std::rand() % (static_cast(emitter.m_maxAngle + 360 - emitter.m_minAngle + 1))))%360); @@ -47,8 +39,6 @@ void ParticleSystem::emitParticle(ParticleEmitter& emitter) { { randomAngle = emitter.m_minAngle + (std::rand() % (static_cast(emitter.m_maxAngle - emitter.m_minAngle + 1))); } - - float angleInRadians = randomAngle * (M_PI / 180.0f); float randomSpeedOffset = (static_cast(std::rand()) / RAND_MAX) * (2 * emitter.m_speedOffset) - emitter.m_speedOffset; float velocityX = (emitter.m_speed + randomSpeedOffset) * std::cos(angleInRadians); @@ -57,23 +47,12 @@ void ParticleSystem::emitParticle(ParticleEmitter& emitter) { velocityX, velocityY }; - // std::cout << "emitter.m_endLifespan:" << emitter.m_endLifespan << std::endl; for (size_t i = 0; i < emitter.particles.size(); i++) { if(!emitter.particles[i].active) { - // std::cout << "active " << emitter.particles[i].active << std::endl; - // std::cout << "lifespan " << emitter.particles[i].lifespan << std::endl; - // std::cout << "timeInLife " << emitter.particles[i].timeInLife << std::endl; - // std::cout << "emitter.m_endLifespan" << emitter.m_endLifespan << std::endl; - // std::cout << "initialPositionx" << initialPosition.x << std::endl; - // std::cout << "initialPositiony" << initialPosition.y << std::endl; - // std::cout << "initialVelocityx" << initialVelocity.x << std::endl; - // std::cout << "initialVelocityy" << initialVelocity.y << std::endl; emitter.particles[i].reset(emitter.m_endLifespan, initialPosition, initialVelocity); break; } } - - //emitter.particles.emplace_back(emitter.m_endLifespan, initialPosition, initialVelocity); } diff --git a/src/crepe/ParticleSystem.h b/src/crepe/ParticleSystem.h index fd6d110..7b14f71 100644 --- a/src/crepe/ParticleSystem.h +++ b/src/crepe/ParticleSystem.h @@ -9,7 +9,7 @@ namespace crepe { class ParticleSystem { public: ParticleSystem(); - void update(float deltaTime, std::vector& emitters); + void update(float deltaTime, std::vector>& emitters); private: void emitParticle(ParticleEmitter &emitter); //emits a new particle diff --git a/src/example/CMakeLists.txt b/src/example/CMakeLists.txt index 36ceba1..cbf8e31 100644 --- a/src/example/CMakeLists.txt +++ b/src/example/CMakeLists.txt @@ -15,5 +15,5 @@ endfunction() add_example(audio_internal) add_example(components_internal) add_example(script) -add_example(particel) -target_link_libraries(particel PUBLIC SDL2) +add_example(particle) +target_link_libraries(particle PUBLIC SDL2) diff --git a/src/example/particel.cpp b/src/example/particel.cpp deleted file mode 100644 index c66bbef..0000000 --- a/src/example/particel.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include -#include -#include -#include "SDLApp.h" -#include "ParticleEmitter.h" -#include "ParticleSystem.h" -#include "Particle.h" -#include - -using namespace crepe; - -const int WINDOW_WIDTH = 800; -const int WINDOW_HEIGHT = 600; - -int main(int argc, char* argv[]) { - SDLApp app(WINDOW_WIDTH, WINDOW_HEIGHT); - - if (!app.initialize()) { - std::cerr << "Failed to initialize SDLApp." << std::endl; - return 1; - } - - ParticleSystem particleSystem; - - unsigned int maxParticles = 100; // maximum number of particles - unsigned int emissionRate = 1; // particles created per second - unsigned int speed = 50; // base speed of particles - unsigned int speedOffset = 10; // random offset for particle speed - unsigned int angle = 90; // base angle of particle emission - unsigned int angleOffset = 30; // random offset for particle angle - float beginLifespan = 0.0f; // beginning lifespan of particles - float endLifespan = 2.0f; // ending lifespan of particles - - // Vector to hold all the emitters - std::vector emitters; - - // Loop to create 1000 emitters - for (unsigned int i = 0; i < 1000; ++i) { - ParticleEmitter emitter(maxParticles, emissionRate, speed, speedOffset, angle, angleOffset, beginLifespan, endLifespan); - - // Set a position for each emitter, modifying the position for demonstration - emitter.m_position = {static_cast(200 + (i % 100)), static_cast(200 + (i / 100) * 10)}; // Adjust position for each emitter - - emitters.push_back(emitter); // Add the emitter to the vector - } - float deltaTime = 0.1f; - bool running = true; - std::cout << "start loop " << std::endl; - while (running) { - app.handleEvents(running); - - // Start timing - auto start = std::chrono::high_resolution_clock::now(); - - particleSystem.update(deltaTime, emitters); // update particle system with delta time and emitters - - // End timing - auto end = std::chrono::high_resolution_clock::now(); - std::chrono::duration duration = end - start; // get duration in milliseconds - - std::cout << "Update took " << duration.count() << " ms" << std::endl; - app.clearScreen(); - - start = std::chrono::high_resolution_clock::now(); - // render particles using the drawSquare method from SDLApp - for (const ParticleEmitter& emitter : emitters) { - for (const Particle& particle : emitter.particles) { - if(particle.active)app.drawSquare(particle.position.x, particle.position.y, 5); // draw each particle - } - } - - - app.presentScreen(); - end = std::chrono::high_resolution_clock::now(); - duration = end - start; // get duration in milliseconds - - std::cout << "screen took " << duration.count() << " ms" << std::endl; - - std::this_thread::sleep_for(std::chrono::milliseconds(20)); // simulate ~50 FPS - } - - app.cleanUp(); - return 0; -} diff --git a/src/example/particle.cpp b/src/example/particle.cpp new file mode 100644 index 0000000..fc56230 --- /dev/null +++ b/src/example/particle.cpp @@ -0,0 +1,97 @@ +#include +#include +#include +#include "SDLApp.h" +#include "ParticleEmitter.h" +#include "ParticleSystem.h" +#include "Particle.h" +#include +#include +#include +#include + +using namespace crepe; +using namespace std; + +const int WINDOW_WIDTH = 800; +const int WINDOW_HEIGHT = 600; + +int main(int argc, char* argv[]) { + SDLApp app(WINDOW_WIDTH, WINDOW_HEIGHT); + + if (!app.initialize()) { + cerr << "Failed to initialize SDLApp." << endl; + return 1; + } + + auto & mgr = ComponentManager::get_instance(); + GameObject * game_object[1]; + game_object[0] = new GameObject(0, "Name", "Tag", 0); + + + ParticleSystem particleSystem; + + unsigned int maxParticles = 100; // maximum number of particles + unsigned int emissionRate = 1; // particles created per second + unsigned int speed = 50; // base speed of particles + unsigned int speedOffset = 10; // random offset for particle speed + unsigned int angle = 90; // base angle of particle emission + unsigned int angleOffset = 30; // random offset for particle angle + float beginLifespan = 0.0f; // beginning lifespan of particles + float endLifespan = 2.0f; // ending lifespan of particles + + // Vector to hold all the emitters + // vector emitters; + game_object[0]->add_component(maxParticles, emissionRate, speed, speedOffset, angle, angleOffset, beginLifespan, endLifespan); + + std::vector> emitters = mgr.get_components_by_type(); + + + // Loop to create 1000 emitters + // for (unsigned int i = 0; i < 1000; ++i) { + // ParticleEmitter emitter(maxParticles, emissionRate, speed, speedOffset, angle, angleOffset, beginLifespan, endLifespan); + + // // Set a position for each emitter, modifying the position for demonstration + // emitter.m_position = {static_cast(200 + (i % 100)), static_cast(200 + (i / 100) * 10)}; // Adjust position for each emitter + + // emitters.push_back(emitter); // Add the emitter to the vector + // } + float deltaTime = 0.1f; + bool running = true; + cout << "start loop " << endl; + while (running) { + app.handleEvents(running); + + // Start timing + auto start = chrono::high_resolution_clock::now(); + + particleSystem.update(deltaTime, emitters); // update particle system with delta time and emitters + + // End timing + auto end = chrono::high_resolution_clock::now(); + chrono::duration duration = end - start; // get duration in milliseconds + + cout << "Update took " << duration.count() << " ms" << endl; + app.clearScreen(); + + start = chrono::high_resolution_clock::now(); + // render particles using the drawSquare method from SDLApp + for (const ParticleEmitter& emitter : emitters) { + for (const Particle& particle : emitter.particles) { + if(particle.active)app.drawSquare(particle.position.x, particle.position.y, 5); // draw each particle + } + } + + + app.presentScreen(); + end = chrono::high_resolution_clock::now(); + duration = end - start; // get duration in milliseconds + + cout << "screen took " << duration.count() << " ms" << endl; + + this_thread::sleep_for(chrono::milliseconds(20)); // simulate ~50 FPS + } + + app.cleanUp(); + return 0; +} -- cgit v1.2.3 From d8483cfab70b5aca3baae6e0588924da8b54e090 Mon Sep 17 00:00:00 2001 From: jaroWMR Date: Sun, 20 Oct 2024 14:33:19 +0200 Subject: updated components to have an ID --- src/crepe/CMakeLists.txt | 2 ++ src/crepe/Collider.cpp | 2 +- src/crepe/Collider.h | 2 +- src/crepe/Component.cpp | 2 +- src/crepe/Component.h | 6 ++++-- src/crepe/ComponentManager.hpp | 2 +- src/crepe/ParticleEmitter.cpp | 4 ++-- src/crepe/ParticleEmitter.h | 2 +- src/crepe/PhysicsSystem.cpp | 20 ++++++++++++++++++++ src/crepe/PhysicsSystem.h | 17 +++++++++++++++++ src/crepe/Rigidbody.cpp | 5 +++-- src/crepe/Rigidbody.h | 11 +++++++++-- src/crepe/Sprite.cpp | 2 +- src/crepe/Sprite.h | 2 +- src/crepe/Transform.cpp | 4 ++-- src/crepe/Transform.h | 2 +- src/crepe/api/BehaviorScript.cpp | 2 +- src/example/CMakeLists.txt | 2 ++ src/example/Physics.cpp | 21 +++++++++++++++++++++ 19 files changed, 91 insertions(+), 19 deletions(-) create mode 100644 src/crepe/PhysicsSystem.cpp create mode 100644 src/crepe/PhysicsSystem.h create mode 100644 src/example/Physics.cpp (limited to 'src/example/CMakeLists.txt') diff --git a/src/crepe/CMakeLists.txt b/src/crepe/CMakeLists.txt index 399200b..ae9d51d 100644 --- a/src/crepe/CMakeLists.txt +++ b/src/crepe/CMakeLists.txt @@ -15,6 +15,7 @@ target_sources(crepe PUBLIC Sprite.cpp ScriptSystem.cpp Script.cpp + PhysicsSystem.cpp ) target_sources(crepe PUBLIC FILE_SET HEADERS FILES @@ -35,6 +36,7 @@ target_sources(crepe PUBLIC FILE_SET HEADERS FILES Sprite.h System.h ScriptSystem.h + PhysicsSystem.h ) add_subdirectory(api) diff --git a/src/crepe/Collider.cpp b/src/crepe/Collider.cpp index 3f12afd..3d3f7cb 100644 --- a/src/crepe/Collider.cpp +++ b/src/crepe/Collider.cpp @@ -2,4 +2,4 @@ using namespace crepe; -Collider::Collider(int size) : size(size) {} +Collider::Collider(uint32_t gameObjectId , int size) : Component(gameObjectId), size(size){} diff --git a/src/crepe/Collider.h b/src/crepe/Collider.h index 120da05..69bb0c3 100644 --- a/src/crepe/Collider.h +++ b/src/crepe/Collider.h @@ -6,7 +6,7 @@ namespace crepe { class Collider : public Component { public: - Collider(int size); + Collider(uint32_t gameObjectId,int size); int size; }; diff --git a/src/crepe/Component.cpp b/src/crepe/Component.cpp index d14159c..e2cd7e0 100644 --- a/src/crepe/Component.cpp +++ b/src/crepe/Component.cpp @@ -2,4 +2,4 @@ using namespace crepe; -Component::Component() : active(true) {} +Component::Component(uint32_t id) : gameObjectId(id), active(true) {} diff --git a/src/crepe/Component.h b/src/crepe/Component.h index 16a4ce5..c8fb6bc 100644 --- a/src/crepe/Component.h +++ b/src/crepe/Component.h @@ -1,13 +1,15 @@ #pragma once +#include namespace crepe { class Component { public: - Component(); + Component(uint32_t id); // 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; }; diff --git a/src/crepe/ComponentManager.hpp b/src/crepe/ComponentManager.hpp index 2ea0c70..f19fdcb 100644 --- a/src/crepe/ComponentManager.hpp +++ b/src/crepe/ComponentManager.hpp @@ -30,7 +30,7 @@ void 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)...); + T * instance = new T(id,forward(args)...); // store its unique_ptr in the vector<> components[type][id].push_back(unique_ptr(instance)); } diff --git a/src/crepe/ParticleEmitter.cpp b/src/crepe/ParticleEmitter.cpp index 30cba7c..318c6db 100644 --- a/src/crepe/ParticleEmitter.cpp +++ b/src/crepe/ParticleEmitter.cpp @@ -5,8 +5,8 @@ using namespace crepe; -ParticleEmitter::ParticleEmitter(uint32_t maxParticles, uint32_t emissionRate, uint32_t speed, uint32_t speedOffset, uint32_t angle, uint32_t angleOffset, float m_beginLifespan, float m_endLifespan) - : m_maxParticles(maxParticles), m_emissionRate(emissionRate), m_speed(speed), m_speedOffset(speedOffset), m_position{0, 0}, m_beginLifespan(m_beginLifespan),m_endLifespan(m_endLifespan) { +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(std::time(nullptr))); // initialize random seed std::cout << "Create emitter" << std::endl; m_minAngle = (360 + angle - (angleOffset % 360)) % 360; // calculate minAngle diff --git a/src/crepe/ParticleEmitter.h b/src/crepe/ParticleEmitter.h index 477f492..8cd78a9 100644 --- a/src/crepe/ParticleEmitter.h +++ b/src/crepe/ParticleEmitter.h @@ -10,7 +10,7 @@ namespace crepe { class ParticleEmitter : public Component { public: - ParticleEmitter(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 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 diff --git a/src/crepe/PhysicsSystem.cpp b/src/crepe/PhysicsSystem.cpp new file mode 100644 index 0000000..c24afa2 --- /dev/null +++ b/src/crepe/PhysicsSystem.cpp @@ -0,0 +1,20 @@ +#include "PhysicsSystem.h" +#include "ComponentManager.h" +#include "Rigidbody.h" +#include "Transform.h" +#include + +using namespace crepe; + +PhysicsSystem::PhysicsSystem() { + +} + +void PhysicsSystem::update() { + ComponentManager& mgr = ComponentManager::get_instance(); + std::vector> rigidbodies = mgr.get_components_by_type(); + std::vector> transforms = mgr.get_components_by_type(); + for (Rigidbody& rigidbody : rigidbodies) { + std::cout << rigidbody.gameObjectId << std::endl; + } +} 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/Rigidbody.cpp b/src/crepe/Rigidbody.cpp index 495d908..a610e55 100644 --- a/src/crepe/Rigidbody.cpp +++ b/src/crepe/Rigidbody.cpp @@ -2,5 +2,6 @@ using namespace crepe; -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/Rigidbody.h b/src/crepe/Rigidbody.h index 63a8877..7018e83 100644 --- a/src/crepe/Rigidbody.h +++ b/src/crepe/Rigidbody.h @@ -1,16 +1,23 @@ #pragma once #include "Component.h" +#include 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); int mass; int gravity_scale; - int body_type; + BodyType body_type; }; } // namespace crepe diff --git a/src/crepe/Sprite.cpp b/src/crepe/Sprite.cpp index a5a5e68..7f5bca7 100644 --- a/src/crepe/Sprite.cpp +++ b/src/crepe/Sprite.cpp @@ -5,4 +5,4 @@ using namespace crepe; using namespace std; -Sprite::Sprite(string path) : path(path) {} +Sprite::Sprite(uint32_t gameObjectId, string path) : Component(gameObjectId), path(path) {} diff --git a/src/crepe/Sprite.h b/src/crepe/Sprite.h index 143e702..8c517ed 100644 --- a/src/crepe/Sprite.h +++ b/src/crepe/Sprite.h @@ -8,7 +8,7 @@ namespace crepe { class Sprite : public Component { public: - Sprite(std::string path); + Sprite(uint32_t gameObjectId,std::string path); std::string path; }; diff --git a/src/crepe/Transform.cpp b/src/crepe/Transform.cpp index 0e4b0cf..2fde448 100644 --- a/src/crepe/Transform.cpp +++ b/src/crepe/Transform.cpp @@ -2,5 +2,5 @@ using namespace crepe; -Transform::Transform(int mass, int gravityScale, int bodyType) - : mass(mass), gravity_scale(gravityScale), body_type(bodyType) {} +Transform::Transform(uint32_t gameObjectId,int mass, int gravityScale, int bodyType) + : Component(gameObjectId), mass(mass), gravity_scale(gravityScale), body_type(bodyType) {} diff --git a/src/crepe/Transform.h b/src/crepe/Transform.h index c72ebc4..96da1a4 100644 --- a/src/crepe/Transform.h +++ b/src/crepe/Transform.h @@ -6,7 +6,7 @@ namespace crepe { class Transform : public Component { public: - Transform(int mass, int gravityScale, int bodyType); + Transform(uint32_t gameObjectId,int mass, int gravityScale, int bodyType); int mass; int gravity_scale; 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/example/CMakeLists.txt b/src/example/CMakeLists.txt index cbf8e31..256d87e 100644 --- a/src/example/CMakeLists.txt +++ b/src/example/CMakeLists.txt @@ -16,4 +16,6 @@ add_example(audio_internal) add_example(components_internal) add_example(script) add_example(particle) +add_example(Physics) target_link_libraries(particle PUBLIC SDL2) +target_link_libraries(Physics PUBLIC SDL2) diff --git a/src/example/Physics.cpp b/src/example/Physics.cpp new file mode 100644 index 0000000..61a3bf2 --- /dev/null +++ b/src/example/Physics.cpp @@ -0,0 +1,21 @@ +#include +#include +#include +#include "Rigidbody.h" +#include "PhysicsSystem.h" +#include +#include +#include + +using namespace crepe; +using namespace std; + + +int main(int argc, char* argv[]) { + PhysicsSystem physicsSystem; + GameObject * game_object[1]; + game_object[0] = new GameObject(5, "Name", "Tag", 0); + game_object[0]->add_component(10, 11 , BodyType::Dynamic); + physicsSystem.update(); + return 0; +} -- cgit v1.2.3