mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-14 16:09:06 +07:00
add audio sample data
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
-DDEBUG
|
|
||||||
-Iheaders
|
-Iheaders
|
||||||
-Isources
|
-Isources
|
||||||
-std=c++14
|
-std=c++17
|
||||||
-stdlib=libc++
|
-stdlib=libc++
|
||||||
|
|||||||
3
samples/bin/kenney_rpgaudio.zip
Normal file
3
samples/bin/kenney_rpgaudio.zip
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:6dbeaf8544da958d8f2adcb4a4a4b76c1ade34a05f8ab9edccd327da7375f38b
|
||||||
|
size 964837
|
||||||
@@ -1,3 +1,8 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
#include "../common.hpp"
|
#include "../common.hpp"
|
||||||
using namespace e2d;
|
using namespace e2d;
|
||||||
@@ -7,39 +12,36 @@ namespace
|
|||||||
class game final : public engine::application {
|
class game final : public engine::application {
|
||||||
public:
|
public:
|
||||||
bool initialize() final {
|
bool initialize() final {
|
||||||
|
the<vfs>().register_scheme<archive_file_source>(
|
||||||
|
"rpgaudio",
|
||||||
|
the<vfs>().read(url("resources://bin/kenney_rpgaudio.zip")));
|
||||||
|
|
||||||
|
the<vfs>().register_scheme_alias(
|
||||||
|
"audio",
|
||||||
|
url("rpgaudio://Audio"));
|
||||||
|
|
||||||
auto fs_file = std::make_unique<filesystem_file_source>();
|
auto sstream1 = the<audio>().preload_stream(the<vfs>().read(url("audio://chop.ogg")));
|
||||||
|
auto sstream2 = the<audio>().create_stream(the<vfs>().read(url("audio://footstep00.ogg")));
|
||||||
auto sstream1 = the<audio>().preload_stream(fs_file->read("bin/library/Example.ogg"));
|
|
||||||
auto sstream2 = the<audio>().create_stream(fs_file->read("bin/library/Example.ogg"));
|
|
||||||
|
|
||||||
if ( !sstream1 || !sstream2 ) {
|
if ( !sstream1 || !sstream2 ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
sound_src1_ = the<audio>().create_source(sstream2);
|
sound_src1_ = the<audio>().create_source(sstream1);
|
||||||
sound_src2_ = the<audio>().create_source(sstream1);
|
sound_src2_ = the<audio>().create_source(sstream2);
|
||||||
sound_src3_ = the<audio>().create_source(sstream1);
|
|
||||||
|
|
||||||
if ( !sound_src1_ || !sound_src2_ || !sound_src3_ ) {
|
if ( !sound_src1_ || !sound_src2_ ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
sound_src1_->play();
|
|
||||||
sound_src1_->looping(true);
|
|
||||||
|
|
||||||
sound_src2_->position(secf(1.0f));
|
|
||||||
sound_src2_->looping(true);
|
sound_src2_->looping(true);
|
||||||
sound_src2_->play();
|
sound_src2_->play();
|
||||||
|
|
||||||
sound_src3_->position(secf(2.0f));
|
|
||||||
sound_src3_->looping(true);
|
|
||||||
sound_src3_->play();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool frame_tick() final {
|
bool frame_tick() final {
|
||||||
|
const mouse& m = the<input>().mouse();
|
||||||
const keyboard& k = the<input>().keyboard();
|
const keyboard& k = the<input>().keyboard();
|
||||||
|
|
||||||
if ( the<window>().should_close() || k.is_key_just_released(keyboard_key::escape) ) {
|
if ( the<window>().should_close() || k.is_key_just_released(keyboard_key::escape) ) {
|
||||||
@@ -54,6 +56,11 @@ namespace
|
|||||||
the<window>().toggle_fullscreen(!the<window>().fullscreen());
|
the<window>().toggle_fullscreen(!the<window>().fullscreen());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( m.is_any_button_pressed() ) {
|
||||||
|
sound_src1_->volume(m.cursor_pos().x / the<window>().real_size().x);
|
||||||
|
sound_src1_->play();
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +74,6 @@ namespace
|
|||||||
private:
|
private:
|
||||||
sound_source_ptr sound_src1_;
|
sound_source_ptr sound_src1_;
|
||||||
sound_source_ptr sound_src2_;
|
sound_source_ptr sound_src2_;
|
||||||
sound_source_ptr sound_src3_;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user