aboutsummaryrefslogtreecommitdiff
path: root/src/crepe
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-06 15:28:12 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-06 15:28:12 +0200
commitaa8755148cbca29b584f7a146636b506070717f9 (patch)
tree275644d2f2cbf5de1c0aa82a3cb05df03ea9fff4 /src/crepe
parent39815f58e3842bb28e644e83111a619bd1374855 (diff)
move components to separate files
Diffstat (limited to 'src/crepe')
-rw-r--r--src/crepe/CMakeLists.txt10
-rw-r--r--src/crepe/Collider.cpp6
-rw-r--r--src/crepe/Collider.h15
-rw-r--r--src/crepe/Component.cpp6
-rw-r--r--src/crepe/Component.h15
-rw-r--r--src/crepe/ComponentManager.h2
-rw-r--r--src/crepe/Components.cpp13
-rw-r--r--src/crepe/Components.h39
-rw-r--r--src/crepe/Rigidbody.cpp7
-rw-r--r--src/crepe/Rigidbody.h16
-rw-r--r--src/crepe/Sprite.cpp9
-rw-r--r--src/crepe/Sprite.h17
12 files changed, 100 insertions, 55 deletions
diff --git a/src/crepe/CMakeLists.txt b/src/crepe/CMakeLists.txt
index 5840208..d7d563e 100644
--- a/src/crepe/CMakeLists.txt
+++ b/src/crepe/CMakeLists.txt
@@ -3,8 +3,11 @@ target_sources(crepe PUBLIC
Sound.cpp
SoundContext.cpp
ComponentManager.cpp
- Components.cpp
+ Component.cpp
GameObject.cpp
+ Collider.cpp
+ Rigidbody.cpp
+ Sprite.cpp
)
target_sources(crepe PUBLIC FILE_SET HEADERS FILES
@@ -13,9 +16,12 @@ target_sources(crepe PUBLIC FILE_SET HEADERS FILES
SoundContext.h
ComponentManager.h
ComponentManager.hpp
- Components.h
+ Component.h
GameObject.h
GameObject.hpp
+ Collider.h
+ Rigidbody.h
+ Sprite.h
)
add_subdirectory(api)
diff --git a/src/crepe/Collider.cpp b/src/crepe/Collider.cpp
new file mode 100644
index 0000000..b7040eb
--- /dev/null
+++ b/src/crepe/Collider.cpp
@@ -0,0 +1,6 @@
+#include "Collider.h"
+
+using namespace crepe;
+
+Collider::Collider(int size) : size(size) {}
+
diff --git a/src/crepe/Collider.h b/src/crepe/Collider.h
new file mode 100644
index 0000000..666386d
--- /dev/null
+++ b/src/crepe/Collider.h
@@ -0,0 +1,15 @@
+#pragma once
+
+#include "Component.h"
+
+namespace crepe {
+
+class Collider : public Component {
+public:
+ Collider(int size);
+
+ int size;
+};
+
+}
+
diff --git a/src/crepe/Component.cpp b/src/crepe/Component.cpp
new file mode 100644
index 0000000..9a7731a
--- /dev/null
+++ b/src/crepe/Component.cpp
@@ -0,0 +1,6 @@
+#include "Component.h"
+
+using namespace crepe;
+
+Component::Component() : active(true) {}
+
diff --git a/src/crepe/Component.h b/src/crepe/Component.h
new file mode 100644
index 0000000..6e23d93
--- /dev/null
+++ b/src/crepe/Component.h
@@ -0,0 +1,15 @@
+#pragma once
+
+namespace crepe {
+
+class Component {
+public:
+ Component();
+ // TODO: shouldn't this constructor be deleted because this class will never
+ // directly be instantiated?
+
+ bool active;
+};
+
+} // namespace crepe
+
diff --git a/src/crepe/ComponentManager.h b/src/crepe/ComponentManager.h
index 9e559dd..9463558 100644
--- a/src/crepe/ComponentManager.h
+++ b/src/crepe/ComponentManager.h
@@ -7,7 +7,7 @@
#include <utility>
#include <vector>
-#include "Components.h"
+#include "Component.h"
namespace crepe {
diff --git a/src/crepe/Components.cpp b/src/crepe/Components.cpp
deleted file mode 100644
index f27c7a4..0000000
--- a/src/crepe/Components.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-#include "Components.h"
-
-using namespace crepe;
-using namespace std;
-
-Component::Component() : active(true) {}
-
-Sprite::Sprite(string path) : path(path) {}
-
-Rigidbody::Rigidbody(int mass, int gravityScale, int bodyType)
- : mass(mass), gravity_scale(gravityScale), body_type(bodyType) {}
-
-Collider::Collider(int size) : size(size) {}
diff --git a/src/crepe/Components.h b/src/crepe/Components.h
deleted file mode 100644
index 139599c..0000000
--- a/src/crepe/Components.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#pragma once
-
-#include <string>
-
-namespace crepe {
-
-class Component {
-public:
- Component();
-
- bool active;
-};
-
-// TODO: these should be in separate files
-
-class Sprite : public Component {
-public:
- Sprite(std::string path);
-
- std::string path;
-};
-
-class Rigidbody : public Component {
-public:
- Rigidbody(int mass, int gravityScale, int bodyType);
-
- int mass;
- int gravity_scale;
- int body_type;
-};
-
-class Collider : public Component {
-public:
- Collider(int size);
-
- int size;
-};
-
-} // namespace crepe
diff --git a/src/crepe/Rigidbody.cpp b/src/crepe/Rigidbody.cpp
new file mode 100644
index 0000000..1518d28
--- /dev/null
+++ b/src/crepe/Rigidbody.cpp
@@ -0,0 +1,7 @@
+#include "Rigidbody.h"
+
+using namespace crepe;
+
+Rigidbody::Rigidbody(int mass, int gravityScale, int bodyType)
+ : mass(mass), gravity_scale(gravityScale), body_type(bodyType) {}
+
diff --git a/src/crepe/Rigidbody.h b/src/crepe/Rigidbody.h
new file mode 100644
index 0000000..67edb03
--- /dev/null
+++ b/src/crepe/Rigidbody.h
@@ -0,0 +1,16 @@
+#pragma once
+
+#include "Component.h"
+
+namespace crepe {
+
+class Rigidbody : public Component {
+public:
+ Rigidbody(int mass, int gravityScale, int bodyType);
+
+ int mass;
+ int gravity_scale;
+ int body_type;
+};
+
+}
diff --git a/src/crepe/Sprite.cpp b/src/crepe/Sprite.cpp
new file mode 100644
index 0000000..c835d83
--- /dev/null
+++ b/src/crepe/Sprite.cpp
@@ -0,0 +1,9 @@
+#include <string>
+
+#include "Sprite.h"
+
+using namespace crepe;
+using namespace std;
+
+Sprite::Sprite(string path) : path(path) {}
+
diff --git a/src/crepe/Sprite.h b/src/crepe/Sprite.h
new file mode 100644
index 0000000..029064b
--- /dev/null
+++ b/src/crepe/Sprite.h
@@ -0,0 +1,17 @@
+#pragma once
+
+#include <string>
+
+#include "Component.h"
+
+namespace crepe {
+
+class Sprite : public Component {
+public:
+ Sprite(std::string path);
+
+ std::string path;
+};
+
+}
+