diff options
Diffstat (limited to 'src/example')
-rw-r--r-- | src/example/asset_manager.cpp | 22 | ||||
-rw-r--r-- | src/example/audio_internal.cpp | 16 | ||||
-rw-r--r-- | src/example/particles.cpp | 5 | ||||
-rw-r--r-- | src/example/rendering.cpp | 6 |
4 files changed, 29 insertions, 20 deletions
diff --git a/src/example/asset_manager.cpp b/src/example/asset_manager.cpp index cf64f89..a2ca8c3 100644 --- a/src/example/asset_manager.cpp +++ b/src/example/asset_manager.cpp @@ -8,7 +8,7 @@ int main() { // this needs to be called before the asset manager otherwise the destructor // of sdl is not in the right order - { Texture test("../asset/texture/img.png"); } + { Texture test("asset/texture/img.png"); } // FIXME: make it so the issue described by the above comment is not possible // (i.e. the order in which internal classes are instantiated should not // impact the way the engine works). @@ -18,20 +18,20 @@ int main() { { // TODO: [design] the Sound class can't be directly included by the user as // it includes SoLoud headers. - auto bgm = mgr.cache<Sound>("../mwe/audio/bgm.ogg"); - auto sfx1 = mgr.cache<Sound>("../mwe/audio/sfx1.wav"); - auto sfx2 = mgr.cache<Sound>("../mwe/audio/sfx2.wav"); + auto bgm = mgr.cache<Sound>("mwe/audio/bgm.ogg"); + auto sfx1 = mgr.cache<Sound>("mwe/audio/sfx1.wav"); + auto sfx2 = mgr.cache<Sound>("mwe/audio/sfx2.wav"); - auto img = mgr.cache<Texture>("../asset/texture/img.png"); - auto img1 = mgr.cache<Texture>("../asset/texture/second.png"); + auto img = mgr.cache<Texture>("asset/texture/img.png"); + auto img1 = mgr.cache<Texture>("asset/texture/second.png"); } { - auto bgm = mgr.cache<Sound>("../mwe/audio/bgm.ogg"); - auto sfx1 = mgr.cache<Sound>("../mwe/audio/sfx1.wav"); - auto sfx2 = mgr.cache<Sound>("../mwe/audio/sfx2.wav"); + auto bgm = mgr.cache<Sound>("mwe/audio/bgm.ogg"); + auto sfx1 = mgr.cache<Sound>("mwe/audio/sfx1.wav"); + auto sfx2 = mgr.cache<Sound>("mwe/audio/sfx2.wav"); - auto img = mgr.cache<Texture>("../asset/texture/img.png"); - auto img1 = mgr.cache<Texture>("../asset/texture/second.png"); + auto img = mgr.cache<Texture>("asset/texture/img.png"); + auto img1 = mgr.cache<Texture>("asset/texture/second.png"); } } diff --git a/src/example/audio_internal.cpp b/src/example/audio_internal.cpp index ff55a59..9b60e6b 100644 --- a/src/example/audio_internal.cpp +++ b/src/example/audio_internal.cpp @@ -4,7 +4,9 @@ */ #include <crepe/api/Config.h> +#include <crepe/facade/SoundContext.h> #include <crepe/facade/Sound.h> +#include <crepe/Asset.h> #include <crepe/util/Log.h> #include <thread> @@ -24,12 +26,18 @@ int _ = []() { }(); int main() { + SoundContext ctx{}; + Sound sound{ctx}; // Load a background track (Ogg Vorbis) - auto bgm = Sound("../mwe/audio/bgm.ogg"); + auto _bgm = sound.clone(Asset{"mwe/audio/bgm.ogg"}); + Sound & bgm = *dynamic_cast<Sound *>(_bgm.get()); // Load three short samples (WAV) - auto sfx1 = Sound("../mwe/audio/sfx1.wav"); - auto sfx2 = Sound("../mwe/audio/sfx2.wav"); - auto sfx3 = Sound("../mwe/audio/sfx3.wav"); + auto _sfx1 = sound.clone(Asset{"mwe/audio/sfx1.wav"}); + Sound & sfx1 = *dynamic_cast<Sound *>(_sfx1.get()); + auto _sfx2 = sound.clone(Asset{"mwe/audio/sfx2.wav"}); + Sound & sfx2 = *dynamic_cast<Sound *>(_sfx2.get()); + auto _sfx3 = sound.clone(Asset{"mwe/audio/sfx3.wav"}); + Sound & sfx3 = *dynamic_cast<Sound *>(_sfx3.get()); // Start the background track bgm.play(); diff --git a/src/example/particles.cpp b/src/example/particles.cpp index 6eab046..b65671a 100644 --- a/src/example/particles.cpp +++ b/src/example/particles.cpp @@ -14,10 +14,11 @@ using namespace crepe; using namespace std; int main(int argc, char * argv[]) { - GameObject game_object(0, "", "", Vector2{0, 0}, 0, 0); + ComponentManager mgr; + GameObject game_object = mgr.new_object("", "", Vector2{0, 0}, 0, 0); Color color(0, 0, 0, 0); Sprite test_sprite = game_object.add_component<Sprite>( - make_shared<Texture>("../asset/texture/img.png"), color, + make_shared<Texture>("asset/texture/img.png"), color, FlipSettings{true, true}); game_object.add_component<ParticleEmitter>(ParticleEmitter::Data{ .position = {0, 0}, diff --git a/src/example/rendering.cpp b/src/example/rendering.cpp index abd11b1..2157bdc 100644 --- a/src/example/rendering.cpp +++ b/src/example/rendering.cpp @@ -31,21 +31,21 @@ int main() { { Color color(0, 0, 0, 0); obj.add_component<Sprite>( - make_shared<Texture>("../asset/texture/img.png"), color, + make_shared<Texture>("asset/texture/img.png"), color, FlipSettings{false, false}); obj.add_component<Camera>(Color::get_red()); } { Color color(0, 0, 0, 0); obj1.add_component<Sprite>( - make_shared<Texture>("../asset/texture/second.png"), color, + 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"); + auto img = mgr.cache<Texture>("asset/texture/second.png"); obj2.add_component<Sprite>(img, color, FlipSettings{true, true}); } */ |