aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contributing.md156
-rw-r--r--src/crepe/CMakeLists.txt12
-rw-r--r--src/crepe/SDLContext.h2
-rw-r--r--src/crepe/system/CMakeLists.txt15
-rw-r--r--src/crepe/system/CollisionSystem.cpp (renamed from src/crepe/CollisionSystem.cpp)0
-rw-r--r--src/crepe/system/CollisionSystem.h (renamed from src/crepe/CollisionSystem.h)0
-rw-r--r--src/crepe/system/ParticleSystem.cpp (renamed from src/crepe/ParticleSystem.cpp)4
-rw-r--r--src/crepe/system/ParticleSystem.h (renamed from src/crepe/ParticleSystem.h)2
-rw-r--r--src/crepe/system/PhysicsSystem.cpp (renamed from src/crepe/PhysicsSystem.cpp)8
-rw-r--r--src/crepe/system/PhysicsSystem.h (renamed from src/crepe/PhysicsSystem.h)0
-rw-r--r--src/crepe/system/RenderSystem.cpp (renamed from src/crepe/RenderSystem.cpp)10
-rw-r--r--src/crepe/system/RenderSystem.h (renamed from src/crepe/RenderSystem.h)0
-rw-r--r--src/crepe/system/ScriptSystem.cpp (renamed from src/crepe/ScriptSystem.cpp)8
-rw-r--r--src/crepe/system/ScriptSystem.h (renamed from src/crepe/ScriptSystem.h)0
-rw-r--r--src/crepe/system/System.h (renamed from src/crepe/System.h)0
-rw-r--r--src/example/asset_manager.cpp2
-rw-r--r--src/example/particle.cpp13
-rw-r--r--src/example/physics.cpp7
-rw-r--r--src/example/rendering.cpp4
-rw-r--r--src/example/script.cpp2
20 files changed, 138 insertions, 107 deletions
diff --git a/contributing.md b/contributing.md
index 38a83fd..35d777d 100644
--- a/contributing.md
+++ b/contributing.md
@@ -1,11 +1,15 @@
-# Contributing new code
+This document contains
+<details><summary>
+examples
+</summary>
+that you can click on to open them.
+</details>
+
+# Git
- Please do the following *before* sending a pull request:
- Merge upstream code (if any) back into your own branch
- Run formatters/linters
-
-# Git
-
- Push as often as possible
- Development is done on separate branches, these follow a pattern of
`name/feature` (i.e. `loek/dll-so-poc` or `jaro/class2`)
@@ -17,8 +21,9 @@
- Formatting nitty-gritty is handled by clang-format/clang-tidy (run `make
format` in the root folder of this repository to format all sources files)
-- ASCII only
- <table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+- <details><summary>
+ ASCII only
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
```cpp
// crepe startup message
@@ -30,9 +35,10 @@
// crêpe startup message
std::string message = "こんにちは世界";
```
- </td></tr></table>
-- Class names are always singular
- <table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+ </td></tr></table></details>
+- <details><summary>
+ Class names are always singular
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
```cpp
class Foo {};
@@ -42,7 +48,7 @@
```cpp
class Cars {};
```
- </td></tr></table>
+ </td></tr></table></details>
- Source files contain the following types of comments:
- What is the code supposed to do (optional)
- Implementation details (if applicable)
@@ -50,8 +56,9 @@
- Usage documentation (required)
- Implementation details (if they affect the header)
- Design/data structure decisions (if applicable)
-- Comments are placed *above* the line(s) they are explaining
- <table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+- <details><summary>
+ Comments are placed *above* the line(s) they are explaining
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
```cpp
int add(int a, int b) {
@@ -68,7 +75,7 @@
return out;
}
```
- </td></tr></table>
+ </td></tr></table></details>
- Header includes are split into paragraphs separated by a blank line. The
order is:
1. system headers (using `<`brackets`>`)
@@ -80,6 +87,7 @@
> sure to separate the include statements using a blank line (clang-format
> may sort include statements, but does not sort across empty lines).
+ <details><summary>Example</summary>
<table><tr><th>Good</th><th>Bad</th></tr><tr><td>
```cpp
@@ -100,9 +108,10 @@
#include <iostream>
#include "api/Sprite.h"
```
- </td></tr></table>
-- `using namespace` may not be used in header files, only in source files.
- <table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+ </td></tr></table></details>
+- <details><summary>
+ <code>using namespace</code> may not be used in header files, only in source files.
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
example.h:
```cpp
@@ -134,10 +143,12 @@
template <typename T>
T foo();
```
- </td></tr></table>
+ </td></tr></table></details>
-- Getter and setter functions are appropriately prefixed with `get_` and `set_`.
- <table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+- <details><summary>
+ Getter and setter functions are appropriately prefixed with <code>get_</code>
+ and <code>set_</code>.
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
```cpp
class Foo {
@@ -160,12 +171,12 @@
int speed;
};
```
- </td></tr></table>
-
-- A singleton's instance is always accessed using a getter function that
+ </td></tr></table></details>
+- <details><summary>
+ A singleton's instance is always accessed using a getter function that
instantiates its own class as a static variable within the getter function
- scope, instead of storing the instance as a member variable directly:
- <table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+ scope, instead of storing the instance as a member variable directly.
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
```cpp
class Foo {
@@ -186,11 +197,11 @@
};
```
- </td></tr></table>
-
-- Member variable default values should be directly defined in the class/struct
+ </td></tr></table></details>
+- <details><summary>
+ Member variable default values should be directly defined in the class/struct
declaration instead of using the constructor.
- <table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
```cpp
class Foo {
@@ -206,28 +217,39 @@
int speed;
};
```
- </td></tr></table>
-
+ </td></tr></table></details>
- Use of the `auto` type is *not* allowed, with the following exceptions:
- - When naming the item type in a range-based for loop:
-
+ - <details><summary>
+ When naming the item type in a range-based for loop
+ </summary>
+
```cpp
for (auto & item : foo()) {
// ...
}
```
- - When calling template factory methods that explicitly name the return type
+ </details>
+ - <details><summary>
+ When calling template factory methods that explicitly name the return type
in the function call signature
+ </summary>
+
```cpp
auto ptr = make_unique<Foo>();
```
- - When fetching a singleton instance
+ </details>
+ - <details><summary>
+ When fetching a singleton instance
+ </summary>
+
```cpp
auto & mgr = crepe::api::Config::get_instance();
```
+ </details>
-- Only use member initializer lists for non-trivial types.
- <table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+- <details><summary>
+ Only use member initializer lists for non-trivial types.
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
```cpp
class Foo {
@@ -248,10 +270,10 @@
int bar;
};
```
- </td></tr></table>
-
-- C++-style structs should define default values for all non-trivial fields.
- <table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+ </td></tr></table></details>
+- <details><summary>
+ C++-style structs should define default values for all non-trivial fields.
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
```cpp
struct Foo {
@@ -267,11 +289,11 @@
std::string baz;
};
```
- </td></tr></table>
-
-- Declare incomplete classes instead of including the relevant header where
+ </td></tr></table></details>
+- <details><summary>
+ Declare incomplete classes instead of including the relevant header where
possible (i.e. if you only need a reference or raw pointer).
- <table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
```cpp
class Bar;
@@ -288,11 +310,11 @@
Bar & bar;
};
```
- </td></tr></table>
-
-- Template functions are only *declared* in a `.h` header, and *defined* in a
- matching `.hpp` header.
- <table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+ </td></tr></table></details>
+- <details><summary>
+ Template functions are only <i>declared</i> in a <code>.h</code> header, and
+ <i>defined</i> in a matching <code>.hpp</code> header.
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
add.h:
```cpp
@@ -320,11 +342,11 @@
return a + b;
}
```
- </td></tr></table>
-
-- Where possible, end (initializer) lists with a trailing comma (e.g. with
+ </td></tr></table></details>
+- <details><summary>
+ Where possible, end (initializer) lists with a trailing comma (e.g. with
structs, enums)
- <table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
```cpp
enum Color {
@@ -343,9 +365,10 @@
Blue
};
```
- </td></tr></table>
-- `#pragma` should be used instead of include guards
- <table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+ </td></tr></table></details>
+- <details><summary>
+ <code>#pragma</code> should be used instead of include guards
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
```cpp
#pragma once
@@ -362,7 +385,7 @@
#endif
```
- </td></tr></table>
+ </td></tr></table></details>
## CMakeLists-specific
@@ -373,20 +396,25 @@
# Structure
-- All engine-related code is implemented under the `crepe` namespace,
- user-facing APIs under `crepe::api` (the folder structure should also reflect
- this).
+- Files are placed in the appropriate directory:
+ |Path|Purpose|
+ |-|-|
+ |`crepe/`|Auxiliary, managers|
+ |`crepe/api/`|User-facing APIs|
+ |`crepe/util/`|Standalone utilities and helper functions|
+ |`crepe/system/`|(ECS) system classes|
- Do not (indirectly) include private *dependency* headers in API header files,
as these are no longer accessible when the engine is installed
+- All code is implemented under the `crepe` namespace.
- Header files declare either a single class or symbols within a single
namespace.
-- TODO: folder structure
# Documentation
- All documentation is written in U.S. English
-- Doxygen commands are used with a backslash instead of an at-sign.
- <table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+- <details><summary>
+ Doxygen commands are used with a backslash instead of an at-sign.
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
```cpp
/**
@@ -406,7 +434,7 @@
*/
void foo();
```
- </td></tr></table>
+ </td></tr></table></details>
# Libraries
diff --git a/src/crepe/CMakeLists.txt b/src/crepe/CMakeLists.txt
index d938eb8..7f976db 100644
--- a/src/crepe/CMakeLists.txt
+++ b/src/crepe/CMakeLists.txt
@@ -3,17 +3,11 @@ target_sources(crepe PUBLIC
Sound.cpp
SoundContext.cpp
Particle.cpp
- ParticleSystem.cpp
SDLApp.cpp
ComponentManager.cpp
Component.cpp
- ScriptSystem.cpp
- PhysicsSystem.cpp
- CollisionSystem.cpp
Collider.cpp
SDLContext.cpp
-
- RenderSystem.cpp
)
target_sources(crepe PUBLIC FILE_SET HEADERS FILES
@@ -24,15 +18,11 @@ target_sources(crepe PUBLIC FILE_SET HEADERS FILES
ComponentManager.h
ComponentManager.hpp
Component.h
- System.h
- ScriptSystem.h
- PhysicsSystem.h
- CollisionSystem.h
Collider.h
SDLContext.h
- RenderSystem.h
)
add_subdirectory(api)
add_subdirectory(util)
+add_subdirectory(system)
diff --git a/src/crepe/SDLContext.h b/src/crepe/SDLContext.h
index 4d9c1bc..ea05c7b 100644
--- a/src/crepe/SDLContext.h
+++ b/src/crepe/SDLContext.h
@@ -6,7 +6,7 @@
#include "api/Sprite.h"
#include "api/Transform.h"
-#include "RenderSystem.h"
+#include "system/RenderSystem.h"
namespace crepe::api {
class Texture;
diff --git a/src/crepe/system/CMakeLists.txt b/src/crepe/system/CMakeLists.txt
new file mode 100644
index 0000000..ff6f66f
--- /dev/null
+++ b/src/crepe/system/CMakeLists.txt
@@ -0,0 +1,15 @@
+target_sources(crepe PUBLIC
+ ParticleSystem.cpp
+ ScriptSystem.cpp
+ PhysicsSystem.cpp
+ CollisionSystem.cpp
+ RenderSystem.cpp
+)
+
+target_sources(crepe PUBLIC FILE_SET HEADERS FILES
+ System.h
+ ScriptSystem.h
+ PhysicsSystem.h
+ CollisionSystem.h
+ RenderSystem.h
+)
diff --git a/src/crepe/CollisionSystem.cpp b/src/crepe/system/CollisionSystem.cpp
index 55e0fdc..55e0fdc 100644
--- a/src/crepe/CollisionSystem.cpp
+++ b/src/crepe/system/CollisionSystem.cpp
diff --git a/src/crepe/CollisionSystem.h b/src/crepe/system/CollisionSystem.h
index 1e9f1aa..1e9f1aa 100644
--- a/src/crepe/CollisionSystem.h
+++ b/src/crepe/system/CollisionSystem.h
diff --git a/src/crepe/ParticleSystem.cpp b/src/crepe/system/ParticleSystem.cpp
index af6c550..367c7d8 100644
--- a/src/crepe/ParticleSystem.cpp
+++ b/src/crepe/system/ParticleSystem.cpp
@@ -1,9 +1,9 @@
#include <cmath>
#include <ctime>
-#include "api/ParticleEmitter.h"
+#include "../api/ParticleEmitter.h"
+#include "../ComponentManager.h"
-#include "ComponentManager.h"
#include "ParticleSystem.h"
using namespace crepe;
diff --git a/src/crepe/ParticleSystem.h b/src/crepe/system/ParticleSystem.h
index ad96eb0..3ac1d3f 100644
--- a/src/crepe/ParticleSystem.h
+++ b/src/crepe/system/ParticleSystem.h
@@ -1,6 +1,6 @@
#pragma once
-#include "api/ParticleEmitter.h"
+#include "../api/ParticleEmitter.h"
namespace crepe {
diff --git a/src/crepe/PhysicsSystem.cpp b/src/crepe/system/PhysicsSystem.cpp
index 16f4c10..6da714f 100644
--- a/src/crepe/PhysicsSystem.cpp
+++ b/src/crepe/system/PhysicsSystem.cpp
@@ -1,10 +1,10 @@
#include <iostream>
-#include "api/Force.h"
-#include "api/Rigidbody.h"
-#include "api/Transform.h"
+#include "../api/Force.h"
+#include "../api/Rigidbody.h"
+#include "../api/Transform.h"
+#include "../ComponentManager.h"
-#include "ComponentManager.h"
#include "PhysicsSystem.h"
using namespace crepe;
diff --git a/src/crepe/PhysicsSystem.h b/src/crepe/system/PhysicsSystem.h
index 33b4072..33b4072 100644
--- a/src/crepe/PhysicsSystem.h
+++ b/src/crepe/system/PhysicsSystem.h
diff --git a/src/crepe/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp
index fae93f0..599087a 100644
--- a/src/crepe/RenderSystem.cpp
+++ b/src/crepe/system/RenderSystem.cpp
@@ -1,13 +1,13 @@
#include <functional>
#include <vector>
-#include "api/Sprite.h"
-#include "api/Transform.h"
-#include "util/log.h"
+#include "../api/Sprite.h"
+#include "../api/Transform.h"
+#include "../util/log.h"
+#include "../SDLContext.h"
+#include "../ComponentManager.h"
-#include "ComponentManager.h"
#include "RenderSystem.h"
-#include "SDLContext.h"
using namespace crepe;
using namespace crepe::api;
diff --git a/src/crepe/RenderSystem.h b/src/crepe/system/RenderSystem.h
index 4b910a4..4b910a4 100644
--- a/src/crepe/RenderSystem.h
+++ b/src/crepe/system/RenderSystem.h
diff --git a/src/crepe/ScriptSystem.cpp b/src/crepe/system/ScriptSystem.cpp
index 171b490..277b29d 100644
--- a/src/crepe/ScriptSystem.cpp
+++ b/src/crepe/system/ScriptSystem.cpp
@@ -2,11 +2,11 @@
#include <functional>
#include <vector>
-#include "api/BehaviorScript.h"
-#include "api/Script.h"
-#include "util/log.h"
+#include "../api/BehaviorScript.h"
+#include "../api/Script.h"
+#include "../util/log.h"
+#include "../ComponentManager.h"
-#include "ComponentManager.h"
#include "ScriptSystem.h"
using namespace std;
diff --git a/src/crepe/ScriptSystem.h b/src/crepe/system/ScriptSystem.h
index 1f472a0..1f472a0 100644
--- a/src/crepe/ScriptSystem.h
+++ b/src/crepe/system/ScriptSystem.h
diff --git a/src/crepe/System.h b/src/crepe/system/System.h
index ecbb7f5..ecbb7f5 100644
--- a/src/crepe/System.h
+++ b/src/crepe/system/System.h
diff --git a/src/example/asset_manager.cpp b/src/example/asset_manager.cpp
index 7e15d1f..3d68ec0 100644
--- a/src/example/asset_manager.cpp
+++ b/src/example/asset_manager.cpp
@@ -1,5 +1,3 @@
-
-
#include <crepe/Sound.h>
#include <crepe/api/AssetManager.h>
#include <crepe/api/Texture.h>
diff --git a/src/example/particle.cpp b/src/example/particle.cpp
index 53fa213..fb72b9b 100644
--- a/src/example/particle.cpp
+++ b/src/example/particle.cpp
@@ -1,13 +1,14 @@
-#include "Particle.h"
-#include "ParticleSystem.h"
-#include "SDLApp.h"
-#include "api/ParticleEmitter.h"
#include <chrono>
+#include <iostream>
+#include <thread>
+
#include <crepe/Component.h>
#include <crepe/ComponentManager.h>
+#include <crepe/Particle.h>
+#include <crepe/SDLApp.h>
#include <crepe/api/GameObject.h>
-#include <iostream>
-#include <thread>
+#include <crepe/api/ParticleEmitter.h>
+#include <crepe/system/ParticleSystem.h>
using namespace crepe::api;
using namespace crepe;
diff --git a/src/example/physics.cpp b/src/example/physics.cpp
index db69b9b..ae8d4ca 100644
--- a/src/example/physics.cpp
+++ b/src/example/physics.cpp
@@ -1,13 +1,14 @@
-#include "PhysicsSystem.h"
#include <chrono>
+#include <iostream>
+#include <thread>
+
+#include <crepe/system/PhysicsSystem.h>
#include <crepe/Component.h>
#include <crepe/ComponentManager.h>
#include <crepe/api/Force.h>
#include <crepe/api/GameObject.h>
#include <crepe/api/Rigidbody.h>
#include <crepe/api/Transform.h>
-#include <iostream>
-#include <thread>
using namespace crepe::api;
using namespace crepe;
diff --git a/src/example/rendering.cpp b/src/example/rendering.cpp
index 1bf448c..0bc222a 100644
--- a/src/example/rendering.cpp
+++ b/src/example/rendering.cpp
@@ -1,7 +1,5 @@
-
-
#include <crepe/ComponentManager.h>
-#include <crepe/RenderSystem.h>
+#include <crepe/system/RenderSystem.h>
#include <crepe/api/GameObject.h>
#include <crepe/util/log.h>
diff --git a/src/example/script.cpp b/src/example/script.cpp
index 5df26e8..1901078 100644
--- a/src/example/script.cpp
+++ b/src/example/script.cpp
@@ -4,7 +4,7 @@
*/
#include <crepe/ComponentManager.h>
-#include <crepe/ScriptSystem.h>
+#include <crepe/system/ScriptSystem.h>
#include <crepe/util/log.h>
#include <crepe/api/BehaviorScript.h>