aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-10-23 15:21:56 +0200
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-10-23 15:21:56 +0200
commitadb7dfabec4811566308cd072e0542cd7eae8cc1 (patch)
tree669c19049121d7fa841e4e9287eceb2c71860ebb /src/crepe/api
parent194c8c4af559f9ea35b2fc53103415ea1e47fb61 (diff)
parent5445331293854aac26af2d5c6a20cedeaa819383 (diff)
Merge branch 'jaro/poc-physics' into niels/rendering
Diffstat (limited to 'src/crepe/api')
-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
5 files changed, 19 insertions, 10 deletions
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