From f7b7a7f14d0eb5aab3b32c8f7f792a50ff58f247 Mon Sep 17 00:00:00 2001 From: MarcEricMartel Date: Fri, 27 Oct 2023 13:27:00 -0400 Subject: [PATCH] Changements C++20 et retour audio --- SQCSim-common/SQCSim-common.vcxproj | 5 ++++- SQCSim-common/bullet.cpp | 1 - SQCSim-common/define.h | 2 ++ SQCSim-srv/SQCSim-srv.vcxproj | 5 ++++- SQCSim2021/SQCSim2021.vcxproj | 8 ++++---- SQCSim2021/engine.cpp | 15 ++++++++++++--- 6 files changed, 26 insertions(+), 10 deletions(-) diff --git a/SQCSim-common/SQCSim-common.vcxproj b/SQCSim-common/SQCSim-common.vcxproj index 991cd1d..4cebfaf 100644 --- a/SQCSim-common/SQCSim-common.vcxproj +++ b/SQCSim-common/SQCSim-common.vcxproj @@ -76,6 +76,7 @@ true WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true + stdcpp20 Console @@ -90,6 +91,7 @@ true WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true + stdcpp20 Console @@ -104,6 +106,7 @@ true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true + stdcpp20 Console @@ -118,7 +121,7 @@ true NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - stdcpp17 + stdcpp20 Console diff --git a/SQCSim-common/bullet.cpp b/SQCSim-common/bullet.cpp index 873879d..d5e7f91 100644 --- a/SQCSim-common/bullet.cpp +++ b/SQCSim-common/bullet.cpp @@ -20,7 +20,6 @@ bool Bullet::Update(World* world, float elapsedtime, int perframe) { } else if ((m_currentpos - m_startpos).Length() > VIEW_DISTANCE) return true; } - return false; } diff --git a/SQCSim-common/define.h b/SQCSim-common/define.h index 8060703..7fd0139 100644 --- a/SQCSim-common/define.h +++ b/SQCSim-common/define.h @@ -31,6 +31,8 @@ #define TEXTURE_SIZE 512 #define MAX_BULLETS 512 +#define BULLET_TIME .1 + typedef uint8_t BlockType; enum BLOCK_TYPE { BTYPE_AIR, BTYPE_DIRT, BTYPE_GRASS, BTYPE_METAL, BTYPE_ICE, BTYPE_LAST }; typedef uint64_t Timestamp; diff --git a/SQCSim-srv/SQCSim-srv.vcxproj b/SQCSim-srv/SQCSim-srv.vcxproj index 525fc03..d080276 100644 --- a/SQCSim-srv/SQCSim-srv.vcxproj +++ b/SQCSim-srv/SQCSim-srv.vcxproj @@ -76,6 +76,7 @@ true WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true + stdcpp20 Console @@ -90,7 +91,7 @@ true WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - Default + stdcpp20 Console @@ -105,6 +106,7 @@ true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true + stdcpp20 Console @@ -119,6 +121,7 @@ true NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true + stdcpp20 Console diff --git a/SQCSim2021/SQCSim2021.vcxproj b/SQCSim2021/SQCSim2021.vcxproj index d120d7b..9fd58a9 100644 --- a/SQCSim2021/SQCSim2021.vcxproj +++ b/SQCSim2021/SQCSim2021.vcxproj @@ -130,7 +130,7 @@ Level3 Disabled WIN32;_DEBUG;_CONSOLE;NOMINMAX;%(PreprocessorDefinitions) - stdcpp17 + stdcpp20 Console @@ -145,7 +145,7 @@ Level3 Disabled WIN32;_DEBUG;_CONSOLE;NOMINMAX;%(PreprocessorDefinitions) - stdcpp17 + stdcpp20 Console @@ -162,7 +162,7 @@ true true WIN32;NDEBUG;_CONSOLE;NOMINMAX;%(PreprocessorDefinitions) - stdcpp17 + stdcpp20 AnySuitable Speed Fast @@ -184,7 +184,7 @@ true true WIN32;NDEBUG;_CONSOLE;NOMINMAX;%(PreprocessorDefinitions) - stdcpp17 + stdcpp20 AnySuitable Speed Fast diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index b0d8905..40de73a 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -733,10 +733,18 @@ void Engine::Render(float elapsedTime) { m_bullets[x] = new Bullet(m_player.GetPOV() + m_player.GetDirection(), m_player.GetDirection()); break; } - else if (x == MAX_BULLETS - 1) { // S'il y a pas d'espace dans l'array, prendre la place de la premi�re balle de l'array. + else if (x == MAX_BULLETS - 1) { // S'il y a pas d'espace dans l'array, prendre la place de la première balle de l'array. m_bullets[0]->~Bullet(); m_bullets[0] = new Bullet(m_player.GetPOV() + m_player.GetDirection(), m_player.GetDirection()); } + bulletTime = BULLET_TIME; + m_audio.Create3DAudioObj(m_powpow, AUDIO_PATH "pow.wav", m_player.GetPOV(), m_player.GetDirection() * 10, false, .5f); + if (m_flash) { // Coupe le rendering et affiche un frame blanc, pour simuler un flash. + glClearColor(.8f, .8f, .8f, 1.f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + glClearColor(0.f, 0.f, 0.f, 1.f); + return; + } } } else if (m_mouseR) @@ -744,7 +752,7 @@ void Engine::Render(float elapsedTime) { for (int x = 0; x < MAX_BULLETS; ++x) { // Array de bullets en jeu. if (m_bullets[x]) { - for (int b = 0; b < BULLET_UPDATES_PER_FRAME; ++b) + for (int b = 0; b < BULLET_UPDATES_PER_FRAME; ++b) { if (m_bullets[x]->Update(&m_world, elapsedTime, BULLET_UPDATES_PER_FRAME)) { m_bullets[x]->~Bullet(); if (m_whoosh[x]) @@ -758,8 +766,9 @@ void Engine::Render(float elapsedTime) { } else { Vector3f pos = m_bullets[x]->getPos(), vel = m_bullets[x]->getVel(); - m_audio.Render3DAudioObj(m_whoosh[x], pos, vel, 5 - (m_bullets[x]->getPos() - m_player.GetPosition()).Length()); + m_audio.Render3DAudioObj(m_whoosh[x], pos, vel, 5 - (m_bullets[x]->getPos() - m_player.GetPosition()).Length()); } + } } }