WIP
This commit is contained in:
committed by
Jérôme Leclercq
parent
b379518479
commit
292ca60592
@@ -14,6 +14,8 @@
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Platform/Keyboard.hpp>
|
||||
#include <Nazara/Platform/Platform.hpp>
|
||||
#include <Nazara/Platform/Window.hpp>
|
||||
#include <Nazara/Utility/BasicMainloop.hpp>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
@@ -66,14 +68,17 @@ int main()
|
||||
Nz::Vector3f pos = sound.GetPosition() + sound.GetVelocity() * clock.GetElapsedTime().AsSeconds();
|
||||
sound.SetPosition(pos);
|
||||
|
||||
std::cout << "Sound position: " << pos << std::endl;
|
||||
std::cout << "Sound position: " << pos << std::endl;
|
||||
|
||||
// Si la position de la source atteint une certaine position, ou si l'utilisateur appuie sur echap
|
||||
if (pos.x > Nz::Vector3f::Left().x*-50.f || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::Escape))
|
||||
sound.Stop(); // On arrête le son (Stoppant également la boucle)
|
||||
// Si la position de la source atteint une certaine position, ou si l'utilisateur appuie sur echap
|
||||
if (pos.x > Nz::Vector3f::Left().x * -50.f || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::Escape))
|
||||
sound.Stop(); // On arrête le son (Stoppant également la boucle)
|
||||
|
||||
clock.Restart();
|
||||
}
|
||||
clock.Restart();
|
||||
}
|
||||
});
|
||||
|
||||
// La boucle du programme (Pour déplacer le son)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -8,35 +8,49 @@
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Platform/Keyboard.hpp>
|
||||
#include <Nazara/Platform/Platform.hpp>
|
||||
#include <Nazara/Utility/BasicMainloop.hpp>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::filesystem::path resourceDir = "assets/examples";
|
||||
if (!std::filesystem::is_directory(resourceDir) && std::filesystem::is_directory("../.." / resourceDir))
|
||||
resourceDir = "../.." / resourceDir;
|
||||
|
||||
Nz::Modules<Nz::Audio> audio;
|
||||
|
||||
Nz::SoundStreamParams streamParams;
|
||||
streamParams.forceMono = false;
|
||||
|
||||
Nz::Music music;
|
||||
if (!music.OpenFromFile(resourceDir / "Audio/file_example_MP3_700KB.mp3", streamParams))
|
||||
try
|
||||
{
|
||||
std::cout << "Failed to load sound" << std::endl;
|
||||
|
||||
std::filesystem::path resourceDir = "assets/examples";
|
||||
if (!std::filesystem::is_directory(resourceDir) && std::filesystem::is_directory("../.." / resourceDir))
|
||||
resourceDir = "../.." / resourceDir;
|
||||
|
||||
Nz::Modules<Nz::Audio> audio;
|
||||
|
||||
Nz::SoundStreamParams streamParams;
|
||||
streamParams.forceMono = false;
|
||||
|
||||
Nz::Music music;
|
||||
if (!music.OpenFromFile(resourceDir / "Audio/file_example_MP3_700KB.mp3", streamParams))
|
||||
{
|
||||
std::cout << "Failed to load sound" << std::endl;
|
||||
std::getchar();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
std::getchar();
|
||||
return EXIT_FAILURE;
|
||||
|
||||
music.Play();
|
||||
|
||||
std::cout << "Playing sound..." << std::endl;
|
||||
|
||||
Nz::Window window;
|
||||
|
||||
Nz::Clock clock;
|
||||
Nz::BasicMainloop(window, [&] {
|
||||
});
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
|
||||
music.Play();
|
||||
|
||||
std::cout << "Playing sound..." << std::endl;
|
||||
|
||||
while (music.IsPlaying())
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
target("PlayMusic")
|
||||
add_deps("NazaraAudio")
|
||||
add_deps("NazaraAudio", "NazaraUtility", "NazaraPlatform")
|
||||
add_files("main.cpp")
|
||||
|
||||
@@ -50,7 +50,7 @@ int main()
|
||||
Nz::Window& mainWindow = windowing.CreateWindow(Nz::VideoMode(1280, 720), windowTitle);
|
||||
auto& windowSwapchain = renderSystem.CreateSwapchain(mainWindow);
|
||||
|
||||
physSytem.GetPhysWorld().SetGravity({ 0.f, -9.81f, 0.f });
|
||||
//physSytem.GetPhysWorld().SetGravity({ 0.f, -9.81f, 0.f });
|
||||
|
||||
Nz::TextureParams texParams;
|
||||
texParams.renderDevice = device;
|
||||
@@ -516,6 +516,4 @@ int main()
|
||||
});
|
||||
|
||||
return app.Run();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -5,8 +5,12 @@ end
|
||||
target("Showcase")
|
||||
set_group("Examples")
|
||||
set_kind("binary")
|
||||
add_deps("NazaraAudio", "NazaraGraphics", "NazaraPhysics2D", "NazaraPhysics3D", "NazaraWidgets")
|
||||
add_deps("PluginAssimp", { links = {} })
|
||||
add_deps("NazaraAudio", "NazaraGraphics", "NazaraPhysics2D", "NazaraWidgets")
|
||||
if has_config("embed_plugins") then
|
||||
add_deps("PluginAssimp")
|
||||
else
|
||||
add_deps("PluginAssimp", { links = {} })
|
||||
end
|
||||
add_packages("entt")
|
||||
add_files("main.cpp")
|
||||
add_defines("NAZARA_ENTT")
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include <Nazara/Platform.hpp>
|
||||
#include <Nazara/Graphics.hpp>
|
||||
#include <Nazara/Math/PidController.hpp>
|
||||
#include <Nazara/Physics3D.hpp>
|
||||
#include <Nazara/Renderer.hpp>
|
||||
#include <Nazara/Utility.hpp>
|
||||
#include <Nazara/Widgets.hpp>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
target("WidgetDemo")
|
||||
add_deps("NazaraGraphics", "NazaraPhysics3D", "NazaraWidgets")
|
||||
add_deps("NazaraGraphics", "NazaraWidgets")
|
||||
add_packages("entt")
|
||||
add_files("main.cpp")
|
||||
add_defines("NAZARA_ENTT")
|
||||
|
||||
Reference in New Issue
Block a user