aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.vscode/launch.json2
-rw-r--r--.vscode/tasks.json6
-rw-r--r--mwe/ecs-memory-efficient/CMakeLists.txt (renamed from mwe/ecs-homemade/CMakeLists.txt)6
-rw-r--r--mwe/ecs-memory-efficient/inc/ComponentManager.h (renamed from mwe/ecs-homemade/inc/ComponentManager.h)0
-rw-r--r--mwe/ecs-memory-efficient/inc/ComponentManager.hpp (renamed from mwe/ecs-homemade/inc/ComponentManager.hpp)0
-rw-r--r--mwe/ecs-memory-efficient/inc/Components.h (renamed from mwe/ecs-homemade/inc/Components.h)6
-rw-r--r--mwe/ecs-memory-efficient/inc/GameObjectMax.h (renamed from mwe/ecs-homemade/inc/GameObjectMax.h)0
-rw-r--r--mwe/ecs-memory-efficient/inc/GameObjectMax.hpp (renamed from mwe/ecs-homemade/inc/GameObjectMax.hpp)0
-rw-r--r--mwe/ecs-memory-efficient/src/ComponentManager.cpp (renamed from mwe/ecs-homemade/src/ComponentManager.cpp)0
-rw-r--r--mwe/ecs-memory-efficient/src/Components.cpp (renamed from mwe/ecs-homemade/src/Components.cpp)4
-rw-r--r--mwe/ecs-memory-efficient/src/GameObjectMax.cpp (renamed from mwe/ecs-homemade/src/GameObjectMax.cpp)0
-rw-r--r--mwe/ecs-memory-efficient/src/main.cpp (renamed from mwe/ecs-homemade/src/main.cpp)18
12 files changed, 22 insertions, 20 deletions
diff --git a/.vscode/launch.json b/.vscode/launch.json
index 160d242..69e3590 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -5,7 +5,7 @@
"name": "Debug with Ninja",
"type": "cppdbg",
"request": "launch",
- "program": "${workspaceFolder}/mwe/ecs-homemade/build/ecs-homemade.exe",
+ "program": "${workspaceFolder}/mwe/ecs-memory-efficient/build/ecs-memory-efficient.exe",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index 19afa6f..b00cb77 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -9,8 +9,8 @@
"-G",
"Ninja",
"-B",
- "${workspaceFolder}/mwe/ecs-homemade/build", // Create build folder here
- "${workspaceFolder}/mwe/ecs-homemade" // Path to your source directory
+ "${workspaceFolder}/mwe/ecs-memory-efficient/build", // Create build folder here
+ "${workspaceFolder}/mwe/ecs-memory-efficient" // Path to your source directory
],
"group": {
"kind": "build",
@@ -24,7 +24,7 @@
"command": "cmake",
"args": [
"--build",
- "${workspaceFolder}/mwe/ecs-homemade/build" // Build directory
+ "${workspaceFolder}/mwe/ecs-memory-efficient/build" // Build directory
],
"dependsOn": "configure", // Ensure the configure task runs first
"group": {
diff --git a/mwe/ecs-homemade/CMakeLists.txt b/mwe/ecs-memory-efficient/CMakeLists.txt
index 6267c1a..d072907 100644
--- a/mwe/ecs-homemade/CMakeLists.txt
+++ b/mwe/ecs-memory-efficient/CMakeLists.txt
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.5)
-project(ecs-homemade)
+project(ecs-memory-efficient)
# Set the C++ standard (optional, but good practice)
set(CMAKE_CXX_STANDARD 17)
@@ -8,10 +8,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
# Use the debug mode (otherwise breakpoints are not compiled)
set(CMAKE_BUILD_TYPE Debug)
-add_executable(ecs-homemade
+add_executable(ecs-memory-efficient
src/main.cpp
src/ComponentManager.cpp
src/Components.cpp
src/GameObjectMax.cpp
)
-target_include_directories(ecs-homemade PRIVATE "${CMAKE_SOURCE_DIR}/inc")
+target_include_directories(ecs-memory-efficient PRIVATE "${CMAKE_SOURCE_DIR}/inc")
diff --git a/mwe/ecs-homemade/inc/ComponentManager.h b/mwe/ecs-memory-efficient/inc/ComponentManager.h
index 893aa56..893aa56 100644
--- a/mwe/ecs-homemade/inc/ComponentManager.h
+++ b/mwe/ecs-memory-efficient/inc/ComponentManager.h
diff --git a/mwe/ecs-homemade/inc/ComponentManager.hpp b/mwe/ecs-memory-efficient/inc/ComponentManager.hpp
index 53dfddd..53dfddd 100644
--- a/mwe/ecs-homemade/inc/ComponentManager.hpp
+++ b/mwe/ecs-memory-efficient/inc/ComponentManager.hpp
diff --git a/mwe/ecs-homemade/inc/Components.h b/mwe/ecs-memory-efficient/inc/Components.h
index 2645a45..98c5fe7 100644
--- a/mwe/ecs-homemade/inc/Components.h
+++ b/mwe/ecs-memory-efficient/inc/Components.h
@@ -1,5 +1,7 @@
#pragma once
+#include <string>
+
class Component {
public:
Component();
@@ -9,7 +11,9 @@ public:
class Sprite : public Component {
public:
- void Render();
+ Sprite(std::string path);
+
+ std::string mPath;
};
class Rigidbody : public Component {
diff --git a/mwe/ecs-homemade/inc/GameObjectMax.h b/mwe/ecs-memory-efficient/inc/GameObjectMax.h
index f0bcec9..f0bcec9 100644
--- a/mwe/ecs-homemade/inc/GameObjectMax.h
+++ b/mwe/ecs-memory-efficient/inc/GameObjectMax.h
diff --git a/mwe/ecs-homemade/inc/GameObjectMax.hpp b/mwe/ecs-memory-efficient/inc/GameObjectMax.hpp
index 1e952ba..1e952ba 100644
--- a/mwe/ecs-homemade/inc/GameObjectMax.hpp
+++ b/mwe/ecs-memory-efficient/inc/GameObjectMax.hpp
diff --git a/mwe/ecs-homemade/src/ComponentManager.cpp b/mwe/ecs-memory-efficient/src/ComponentManager.cpp
index 16cc2b6..16cc2b6 100644
--- a/mwe/ecs-homemade/src/ComponentManager.cpp
+++ b/mwe/ecs-memory-efficient/src/ComponentManager.cpp
diff --git a/mwe/ecs-homemade/src/Components.cpp b/mwe/ecs-memory-efficient/src/Components.cpp
index 5f10bc5..69b5eaa 100644
--- a/mwe/ecs-homemade/src/Components.cpp
+++ b/mwe/ecs-memory-efficient/src/Components.cpp
@@ -3,9 +3,7 @@
Component::Component() : mActive(true) {}
-void Sprite::Render() {
- std::cout << "Rendering sprite" << std::endl;
-}
+Sprite::Sprite(std::string path) : mPath(path) {}
Rigidbody::Rigidbody(int mass, int gravityScale, int bodyType) : mMass(mass), mGravityScale(gravityScale), mBodyType(bodyType) {}
diff --git a/mwe/ecs-homemade/src/GameObjectMax.cpp b/mwe/ecs-memory-efficient/src/GameObjectMax.cpp
index 62c41de..62c41de 100644
--- a/mwe/ecs-homemade/src/GameObjectMax.cpp
+++ b/mwe/ecs-memory-efficient/src/GameObjectMax.cpp
diff --git a/mwe/ecs-homemade/src/main.cpp b/mwe/ecs-memory-efficient/src/main.cpp
index 9e230e5..9e8fbd5 100644
--- a/mwe/ecs-homemade/src/main.cpp
+++ b/mwe/ecs-memory-efficient/src/main.cpp
@@ -16,16 +16,16 @@ int main() {
GameObject gameObect6(6, "Name: 6", "Tag: 6", 6); //Entity 6
GameObject gameObect7(7, "Name: 7", "Tag: 7", 7); //Entity 7
- gameObect0.AddComponent<Sprite>(); //Add a sprite to entity0
+ gameObect0.AddComponent<Sprite>("C:/object0"); //Add a sprite to entity0
gameObect0.AddComponent<Rigidbody>(1, 2, 3); //Also add a rigidbody to entity0
gameObect0.AddComponent<Rigidbody>(3, 2, 1); //Add a second rigidbody to entity0
gameObect1.AddComponent<Rigidbody>(4, 5, 6); //Only add a rigidbody to entity1
- gameObect2.AddComponent<Sprite>(); //Add four sprites to entity2
- gameObect2.AddComponent<Sprite>();
- gameObect2.AddComponent<Sprite>();
- gameObect2.AddComponent<Sprite>();
+ gameObect2.AddComponent<Sprite>("C:/object2/1"); //Add four sprites to entity2
+ gameObect2.AddComponent<Sprite>("C:/object2/2");
+ gameObect2.AddComponent<Sprite>("C:/object2/3");
+ gameObect2.AddComponent<Sprite>("C:/object2/4");
gameObect2.AddComponent<Rigidbody>(10, 100, 500); //Add four rigidbodies to entity2
gameObect2.AddComponent<Rigidbody>(10, 100, 501);
gameObect2.AddComponent<Rigidbody>(10, 100, 502);
@@ -33,7 +33,7 @@ int main() {
//Add non components to entity3, entity4, entity5 and entity6
- gameObect7.AddComponent<Sprite>(); //Add a sprite to entity 7
+ gameObect7.AddComponent<Sprite>("C:/object7"); //Add a sprite to entity 7
gameObect7.AddComponent<Colider>(30); //Add a colder to entity 7
//The entities are now initialized
@@ -42,7 +42,7 @@ int main() {
std::cout << "Finding all sprites of entity 0" << std::endl;
std::vector<std::reference_wrapper<Sprite>> spriteOfEntity0 = ComponentManager::GetInstance().GetComponentsByID<Sprite>(gameObect0.mId);
for(Sprite& spriteEntity0 : spriteOfEntity0) {
- std::cout << "Sprite of entity 0: " << spriteEntity0.mActive << std::endl;
+ std::cout << "Sprite of entity 0: " << spriteEntity0.mPath << std::endl;
}
std::cout << std::endl;
@@ -65,7 +65,7 @@ int main() {
std::cout << "Finding all sprites of entity 3" << std::endl;
std::vector<std::reference_wrapper<Sprite>> spriteOfEntity3 = ComponentManager::GetInstance().GetComponentsByID<Sprite>(gameObect3.mId);
for(Sprite& spriteEntity3 : spriteOfEntity3) {
- std::cout << "Sprite of entity 3: " << spriteEntity3.mActive << std::endl;
+ std::cout << "Sprite of entity 3: " << spriteEntity3.mPath << std::endl;
}
std::cout << std::endl;
@@ -79,7 +79,7 @@ int main() {
std::cout << "Finding all sprites of all entities" << std::endl;
std::vector<std::pair<std::reference_wrapper<Sprite>, std::uint32_t>> sprites = ComponentManager::GetInstance().GetComponentsByType<Sprite>();
for(auto& [sprite, id] : sprites) {
- std::cout << "Sprite of id: " << id << ": " << sprite.get().mActive << std::endl;
+ std::cout << "Sprite of id: " << id << ": " << sprite.get().mPath << std::endl;
}
std::cout << std::endl;