From 2bcd6ece912ab0a140f9d925718e8787879d1ed7 Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Wed, 11 Dec 2024 14:36:44 +0100 Subject: adjusted aspect ratio --- src/example/rendering_particle.cpp | 4 +-- src/example/sound.cpp | 54 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 src/example/sound.cpp (limited to 'src/example') diff --git a/src/example/rendering_particle.cpp b/src/example/rendering_particle.cpp index 44bd96a..bd4ef95 100644 --- a/src/example/rendering_particle.cpp +++ b/src/example/rendering_particle.cpp @@ -63,8 +63,8 @@ public: .position_offset = {0, 0}, }); - auto & anim = game_object.add_component(test_sprite,ivec2{32, 64}, uvec2{4,1}, Animator::Data{}); - anim.set_anim(0); + //auto & anim = game_object.add_component(test_sprite,ivec2{32, 64}, uvec2{4,1}, Animator::Data{}); + //anim.set_anim(0); auto & cam = game_object.add_component(ivec2{1280, 720}, vec2{400, 400}, Camera::Data{ diff --git a/src/example/sound.cpp b/src/example/sound.cpp new file mode 100644 index 0000000..a9b0930 --- /dev/null +++ b/src/example/sound.cpp @@ -0,0 +1,54 @@ + + +#include "api/Asset.h" +#include "api/AudioSource.h" +#include "api/BehaviorScript.h" +#include "api/Camera.h" +#include "api/GameObject.h" +#include "api/LoopManager.h" +#include "api/Scene.h" +#include "api/Script.h" +#include "manager/ComponentManager.h" +#include "types.h" +#include + +using namespace crepe; + + +class ScriptTest : public Script { + void init(){ + auto & audio = this->get_component(); + audio.play(); + } + void update(){ + } +}; + + +class TestSound : public Scene { +public: + void load_scene(){ + Mediator & mediator = this->mediator; + ComponentManager & mgr = mediator.component_manager; + + GameObject obj = mgr.new_object("SOUND"); + GameObject cam = mgr.new_object("cam"); + cam.add_component(ivec2{100,100},vec2{100,100}, Camera::Data{}); + + Asset asset{"asset/audio/sample.ogg"}; + auto & test = obj.add_component(asset); + obj.add_component().set_script(); + + + } + + std::string get_name() const { return "TestScene"; }; + +}; + +int main(){ + LoopManager engine; + engine.add_scene(); + engine.start(); + return 0; +} -- cgit v1.2.3