From 38c5e1bb819d2bf06b9d8c387726fa285a9a3065 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 18 Dec 2024 13:03:49 +0100 Subject: add test + fix audio crash --- src/example/audio-crash.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/example/audio-crash.cpp (limited to 'src/example/audio-crash.cpp') diff --git a/src/example/audio-crash.cpp b/src/example/audio-crash.cpp new file mode 100644 index 0000000..6c1052e --- /dev/null +++ b/src/example/audio-crash.cpp @@ -0,0 +1,47 @@ +#include +#include +#include +#include +#include + +#define private public +#include + +using namespace crepe; +using namespace std; + +class Auto : public Script { + unsigned i = 0; + void init() { + AudioSource & sound = get_component(); + sound.play(); + } + + void update() { + if (++i < 50) return; + EventManager & evmgr = this->mediator->event_manager; + evmgr.trigger_event(); + } +}; + +class Bug : public Scene { + virtual std::string get_name() const override { return "bug"; } + void load_scene() override { + GameObject camera = new_object("camera"); + camera.add_component(ivec2{10, 10}, vec2{1, 1}, Camera::Data{ }); + + GameObject sound = new_object("sound"); + sound.add_component(Asset{"mwe/audio/bgm.ogg"}); + sound.add_component().set_script(); + } +}; + +int main() { + Config & config = Config::get_instance(); + config.log.level = Log::Level::TRACE; + + LoopManager example; + example.add_scene(); + example.start(); + return 0; +} -- cgit v1.2.3