aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-10-23 14:00:27 +0200
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-10-23 14:00:27 +0200
commit194c8c4af559f9ea35b2fc53103415ea1e47fb61 (patch)
tree93bc71b9978ed5df5afb993f70f051ddda91a2b6 /src/crepe/api
parenteaa05e7a981b0f581f5393882e4753d9294a3dba (diff)
parent04a040e28ade412ea5b1767bf77eed3956121973 (diff)
Merge branch 'master' into niels/rendering
Diffstat (limited to 'src/crepe/api')
-rw-r--r--src/crepe/api/AudioSource.cpp2
-rw-r--r--src/crepe/api/AudioSource.h4
-rw-r--r--src/crepe/api/BehaviorScript.cpp1
-rw-r--r--src/crepe/api/BehaviorScript.h2
-rw-r--r--src/crepe/api/CMakeLists.txt9
-rw-r--r--src/crepe/api/Collider.cpp5
-rw-r--r--src/crepe/api/Collider.h14
-rw-r--r--src/crepe/api/GameObject.cpp7
-rw-r--r--src/crepe/api/GameObject.h24
-rw-r--r--src/crepe/api/GameObject.hpp15
-rw-r--r--src/crepe/api/Rigidbody.cpp6
-rw-r--r--src/crepe/api/Rigidbody.h16
12 files changed, 101 insertions, 4 deletions
diff --git a/src/crepe/api/AudioSource.cpp b/src/crepe/api/AudioSource.cpp
index 90c1b07..b246cc9 100644
--- a/src/crepe/api/AudioSource.cpp
+++ b/src/crepe/api/AudioSource.cpp
@@ -1,3 +1,5 @@
+#include <memory>
+
#include "AudioSource.h"
#include "Sound.h"
diff --git a/src/crepe/api/AudioSource.h b/src/crepe/api/AudioSource.h
index 2d26cda..7980212 100644
--- a/src/crepe/api/AudioSource.h
+++ b/src/crepe/api/AudioSource.h
@@ -2,8 +2,8 @@
#include <memory>
-#include "Asset.h"
-#include "Component.h"
+#include "../Asset.h"
+#include "../Component.h"
namespace crepe {
class Sound;
diff --git a/src/crepe/api/BehaviorScript.cpp b/src/crepe/api/BehaviorScript.cpp
index 1f236b4..84bfd4c 100644
--- a/src/crepe/api/BehaviorScript.cpp
+++ b/src/crepe/api/BehaviorScript.cpp
@@ -1,7 +1,6 @@
#include "../util/log.h"
#include "BehaviorScript.h"
-#include "Script.h"
using namespace crepe::api;
diff --git a/src/crepe/api/BehaviorScript.h b/src/crepe/api/BehaviorScript.h
index 6ce6798..25d3cc5 100644
--- a/src/crepe/api/BehaviorScript.h
+++ b/src/crepe/api/BehaviorScript.h
@@ -2,7 +2,7 @@
#include <memory>
-#include "Component.h"
+#include "../Component.h"
#include "Script.h"
namespace crepe {
diff --git a/src/crepe/api/CMakeLists.txt b/src/crepe/api/CMakeLists.txt
index d29a771..37c194d 100644
--- a/src/crepe/api/CMakeLists.txt
+++ b/src/crepe/api/CMakeLists.txt
@@ -7,12 +7,21 @@ target_sources(crepe PUBLIC
Sprite.cpp
Transform.cpp
AssetManager.cpp
+ GameObject.cpp
+ Collider.cpp
+ Rigidbody.cpp
+ Sprite.cpp
)
target_sources(crepe PUBLIC FILE_SET HEADERS FILES
# AudioSource.h
BehaviorScript.h
Script.h
+ GameObject.h
+ GameObject.hpp
+ Collider.h
+ Rigidbody.h
+ Sprite.h
Point.h
Transform.h
Color.h
diff --git a/src/crepe/api/Collider.cpp b/src/crepe/api/Collider.cpp
new file mode 100644
index 0000000..6370a42
--- /dev/null
+++ b/src/crepe/api/Collider.cpp
@@ -0,0 +1,5 @@
+#include "Collider.h"
+
+using namespace crepe::api;
+
+Collider::Collider(int size) : size(size) {}
diff --git a/src/crepe/api/Collider.h b/src/crepe/api/Collider.h
new file mode 100644
index 0000000..72d8e77
--- /dev/null
+++ b/src/crepe/api/Collider.h
@@ -0,0 +1,14 @@
+#pragma once
+
+#include "../Component.h"
+
+namespace crepe::api {
+
+class Collider : public Component {
+public:
+ Collider(int size);
+
+ int size;
+};
+
+} // namespace crepe::api
diff --git a/src/crepe/api/GameObject.cpp b/src/crepe/api/GameObject.cpp
new file mode 100644
index 0000000..b167187
--- /dev/null
+++ b/src/crepe/api/GameObject.cpp
@@ -0,0 +1,7 @@
+#include "GameObject.h"
+
+using namespace crepe::api;
+using namespace std;
+
+GameObject::GameObject(uint32_t id, string name, string tag, int layer)
+ : id(id), name(name), tag(tag), active(true), layer(layer) {}
diff --git a/src/crepe/api/GameObject.h b/src/crepe/api/GameObject.h
new file mode 100644
index 0000000..57508c5
--- /dev/null
+++ b/src/crepe/api/GameObject.h
@@ -0,0 +1,24 @@
+#pragma once
+
+#include <cstdint>
+#include <string>
+
+namespace crepe::api {
+
+class GameObject {
+public:
+ GameObject(uint32_t id, std::string name, std::string tag, int layer);
+
+ template <typename T, typename... Args>
+ T & add_component(Args &&... args);
+
+ uint32_t id;
+ std::string name;
+ std::string tag;
+ bool active;
+ int layer;
+};
+
+} // namespace crepe::api
+
+#include "GameObject.hpp"
diff --git a/src/crepe/api/GameObject.hpp b/src/crepe/api/GameObject.hpp
new file mode 100644
index 0000000..8295ea3
--- /dev/null
+++ b/src/crepe/api/GameObject.hpp
@@ -0,0 +1,15 @@
+#pragma once
+
+#include "../ComponentManager.h"
+
+#include "GameObject.h"
+
+namespace crepe::api {
+
+template <typename T, typename... Args>
+T & GameObject::add_component(Args &&... args) {
+ auto & mgr = ComponentManager::get_instance();
+ return mgr.add_component<T>(id, std::forward<Args>(args)...);
+}
+
+} // namespace crepe::api
diff --git a/src/crepe/api/Rigidbody.cpp b/src/crepe/api/Rigidbody.cpp
new file mode 100644
index 0000000..98d1d60
--- /dev/null
+++ b/src/crepe/api/Rigidbody.cpp
@@ -0,0 +1,6 @@
+#include "Rigidbody.h"
+
+using namespace crepe::api;
+
+Rigidbody::Rigidbody(int mass, int gravityScale, int bodyType)
+ : mass(mass), gravity_scale(gravityScale), body_type(bodyType) {}
diff --git a/src/crepe/api/Rigidbody.h b/src/crepe/api/Rigidbody.h
new file mode 100644
index 0000000..6cae579
--- /dev/null
+++ b/src/crepe/api/Rigidbody.h
@@ -0,0 +1,16 @@
+#pragma once
+
+#include "../Component.h"
+
+namespace crepe::api {
+
+class Rigidbody : public Component {
+public:
+ Rigidbody(int mass, int gravityScale, int bodyType);
+
+ int mass;
+ int gravity_scale;
+ int body_type;
+};
+
+} // namespace crepe::api