aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--asset/texture/ERROR.pngbin0 -> 3581 bytes
-rw-r--r--contributing.md14
-rw-r--r--src/crepe/facade/SDLContext.cpp2
-rw-r--r--src/crepe/system/RenderSystem.cpp4
-rw-r--r--src/example/rendering.cpp11
6 files changed, 24 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
index 180afb8..8bfb819 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,4 +15,4 @@ compile_commands.json
CTestTestfile.cmake
_deps
CMakeUserPresets.json
-
+compile.sh
diff --git a/asset/texture/ERROR.png b/asset/texture/ERROR.png
new file mode 100644
index 0000000..2af3548
--- /dev/null
+++ b/asset/texture/ERROR.png
Binary files differ
diff --git a/contributing.md b/contributing.md
index 8799057..a80f2b4 100644
--- a/contributing.md
+++ b/contributing.md
@@ -652,6 +652,20 @@ that you can click on to open them.
bool bar = 0;
```
</td></tr></table></details>
+- <details><summary>
+ The reason for <code>friend</code> relations are documented
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+
+ ```cpp
+ //! ComponentManager calls the private constructor of this class
+ friend class ComponentManager;
+ ```
+ </td><td>
+
+ ```cpp
+ friend class ComponentManager;
+ ```
+ </td></tr></table></details>
## CMakeLists-specific
diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp
index c4c96e2..e87a2c5 100644
--- a/src/crepe/facade/SDLContext.cpp
+++ b/src/crepe/facade/SDLContext.cpp
@@ -159,7 +159,7 @@ SDLContext::texture_from_path(const std::string & path) {
SDL_Surface * tmp = IMG_Load(path.c_str());
if (tmp == nullptr) {
- throw Exception("surface cannot be load from %s", path.c_str());
+ tmp = IMG_Load("../asset/texture/ERROR.png");
}
std::unique_ptr<SDL_Surface, std::function<void(SDL_Surface *)>>
diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp
index 10211a3..3a1def5 100644
--- a/src/crepe/system/RenderSystem.cpp
+++ b/src/crepe/system/RenderSystem.cpp
@@ -6,6 +6,7 @@
#include "../api/Transform.h"
#include "../facade/SDLContext.h"
#include "../util/log.h"
+#include "api/ParticleEmitter.h"
#include "RenderSystem.h"
@@ -42,8 +43,7 @@ void RenderSystem::render_sprites() const {
ComponentManager & mgr = ComponentManager::get_instance();
- std::vector<std::reference_wrapper<Sprite>> sprites
- = mgr.get_components_by_type<Sprite>();
+ auto sprites = mgr.get_components_by_type<Sprite>();
SDLContext & render = SDLContext::get_instance();
for (const Sprite & sprite : sprites) {
diff --git a/src/example/rendering.cpp b/src/example/rendering.cpp
index d554a8a..e02f6a3 100644
--- a/src/example/rendering.cpp
+++ b/src/example/rendering.cpp
@@ -1,3 +1,4 @@
+#include "api/Camera.h"
#include <crepe/ComponentManager.h>
#include <crepe/api/GameObject.h>
#include <crepe/system/RenderSystem.h>
@@ -23,26 +24,26 @@ int main() {
auto obj1 = GameObject(1, "name", "tag", Vector2{500, 0}, 1, 0.1);
auto obj2 = GameObject(2, "name", "tag", Vector2{800, 0}, 1, 0.1);
- auto & mgr = AssetManager::get_instance();
// Normal adding components
{
Color color(0, 0, 0, 0);
obj.add_component<Sprite>(
make_shared<Texture>("../asset/texture/img.png"), color,
- FlipSettings{true, true});
+ FlipSettings{false, false});
+ obj.add_component<Camera>(Color::get_red());
}
-
{
Color color(0, 0, 0, 0);
- auto img = mgr.cache<Texture>("../asset/texture/second.png");
- obj1.add_component<Sprite>(img, color, FlipSettings{true, true});
+ obj1.add_component<Sprite>(make_shared<Texture>("../asset/texture/second.png"), color, FlipSettings{true, true});
}
+ /*
{
Color color(0, 0, 0, 0);
auto img = mgr.cache<Texture>("../asset/texture/second.png");
obj2.add_component<Sprite>(img, color, FlipSettings{true, true});
}
+ */
auto & sys = crepe::RenderSystem::get_instance();
auto start = std::chrono::steady_clock::now();