Merge branch 'master' into SQC-15_online
This commit is contained in:
@@ -45,7 +45,6 @@ void Engine::Init() {
|
||||
gluPerspective(45.0f, (float)Width() / (float)Height(), 0.1f, VIEW_DISTANCE);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||
glDisable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
@@ -167,7 +166,6 @@ void Engine::LoadResource() {
|
||||
TextureAtlas::TextureIndex StillQuarterBackRightShootFire = m_animeAtlas.AddTexture(ANIM_PATH_SSHOOT2 "BlueBackRightShootingRightShoot1.png"); ////23
|
||||
TextureAtlas::TextureIndex StillBackShootFire = m_animeAtlas.AddTexture(ANIM_PATH_SSHOOT2 "BlueShootingBackRightShoot1.png"); ////24
|
||||
|
||||
|
||||
//JUMP
|
||||
TextureAtlas::TextureIndex JumpFront = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueFrontJumpRight.png"); ////25
|
||||
TextureAtlas::TextureIndex JumpQuarterFrontLeft = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueLeftFrontJumpLeft.png"); ////26
|
||||
@@ -178,7 +176,6 @@ void Engine::LoadResource() {
|
||||
TextureAtlas::TextureIndex JumpQuarterBackRight = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueRightBackJumpRight.png"); ////31
|
||||
TextureAtlas::TextureIndex JumpBack = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueBackJumpRight.png"); ////32
|
||||
|
||||
|
||||
//SHOOTINGJUMP SANS TIRER
|
||||
TextureAtlas::TextureIndex JumpFrontShoot = m_animeAtlas.AddTexture(ANIM_PATH_JSHOOT1 "BlueFrontJumpRightShootingRight.png"); ////33
|
||||
TextureAtlas::TextureIndex JumpQuarterFrontLeftShoot = m_animeAtlas.AddTexture(ANIM_PATH_JSHOOT1 "BlueFrontLeftJumpLeftShootingLeft.png"); ////34
|
||||
@@ -189,7 +186,6 @@ void Engine::LoadResource() {
|
||||
TextureAtlas::TextureIndex JumpQuarterBackRightShoot = m_animeAtlas.AddTexture(ANIM_PATH_JSHOOT1 "BlueBackRightJumpRightShootingRight.png"); ////39
|
||||
TextureAtlas::TextureIndex JumpBackShoot = m_animeAtlas.AddTexture(ANIM_PATH_JSHOOT1 "BlueBackJumpRightShootingRight.png"); ////40
|
||||
|
||||
|
||||
//SHOOTINGJUMP TIRER
|
||||
TextureAtlas::TextureIndex JumpFrontShootFire = m_animeAtlas.AddTexture(ANIM_PATH_JSHOOT2 "BlueFrontJumpRightShootingRightShoot1.png"); ////41
|
||||
TextureAtlas::TextureIndex JumpQuarterFrontLeftShootFire = m_animeAtlas.AddTexture(ANIM_PATH_JSHOOT2 "BlueFrontLeftJumpLeftShootingLeftShoot1.png"); ////42
|
||||
@@ -200,8 +196,6 @@ void Engine::LoadResource() {
|
||||
TextureAtlas::TextureIndex JumpQuarterBackRightShootFire = m_animeAtlas.AddTexture(ANIM_PATH_JSHOOT2 "BlueBackRightJumpRightShootingRightShoot1.png"); ////47
|
||||
TextureAtlas::TextureIndex JumpBackShootFire = m_animeAtlas.AddTexture(ANIM_PATH_JSHOOT2 "BlueBackJumpRightShootingRightShoot1.png"); ////48
|
||||
|
||||
|
||||
|
||||
if (!m_animeAtlas.Generate(TEXTURE_SIZE, false)) {
|
||||
std::cout << " Unable to generate texture atlas ..." << std::endl;
|
||||
abort();
|
||||
@@ -244,12 +238,23 @@ void Engine::LoadResource() {
|
||||
std::cout << " Failed to load shader " << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Settings
|
||||
m_mainvolume = m_audio.GetMainVolume();
|
||||
m_options.SetMainVolume(m_mainvolume);
|
||||
|
||||
m_musicvolume = m_audio.GetMusicVolume();
|
||||
m_options.SetMusicVolume(m_musicvolume);
|
||||
|
||||
m_sfxvolume = m_audio.GetSfxVolume();
|
||||
m_options.SetSfxVolume(m_sfxvolume);
|
||||
|
||||
m_sensitivity = m_player.GetSensitivity();
|
||||
m_options.SetMouseSensitivity(m_sensitivity);
|
||||
}
|
||||
|
||||
void Engine::UnloadResource() {}
|
||||
|
||||
|
||||
|
||||
void Engine::InstantDamage() {
|
||||
m_player.InflictDamage(0.10f);
|
||||
m_damage = false;
|
||||
@@ -721,6 +726,7 @@ void Engine::DisplayLobbyMenu(float elapsedTime) {
|
||||
GLint viewport[4];
|
||||
glGetIntegerv(GL_VIEWPORT, viewport);
|
||||
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
@@ -732,6 +738,7 @@ void Engine::DisplayLobbyMenu(float elapsedTime) {
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
m_textureLobbyMenu.Bind();
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0); glVertex2i(0, 0);
|
||||
@@ -740,7 +747,6 @@ void Engine::DisplayLobbyMenu(float elapsedTime) {
|
||||
glTexCoord2f(0, 1); glVertex2i(0, Height());
|
||||
glEnd();
|
||||
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
if (m_settingUsername) {
|
||||
SetPlayerUsername(elapsedTime);
|
||||
@@ -749,9 +755,20 @@ void Engine::DisplayLobbyMenu(float elapsedTime) {
|
||||
SetServerAddress(elapsedTime);
|
||||
}
|
||||
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
m_textureOptBack.Bind();
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0); glVertex2i(Width() * 0.675, Height() * 0.15);
|
||||
glTexCoord2f(1, 0); glVertex2i(Width() * 0.9, Height() * 0.15);
|
||||
glTexCoord2f(1, 1); glVertex2i(Width() * 0.9, Height() * 0.225);
|
||||
glTexCoord2f(0, 1); glVertex2i(Width() * 0.675, Height() * 0.225);
|
||||
glEnd();
|
||||
|
||||
glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
|
||||
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
@@ -760,6 +777,7 @@ void Engine::DisplayLobbyMenu(float elapsedTime) {
|
||||
}
|
||||
|
||||
void Engine::SetPlayerUsername(float elapsedTime) {
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
m_textureLobbyIdentify.Bind();
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0); glVertex2i(Width() * 0.6, Height() * 0.75);
|
||||
@@ -771,11 +789,10 @@ void Engine::SetPlayerUsername(float elapsedTime) {
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
HandlePlayerInput(elapsedTime);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
void Engine::SetServerAddress(float elapsedTime) {
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
m_textureLobbyServer.Bind();
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0); glVertex2i(Width() * 0.6, Height() * 0.75);
|
||||
@@ -788,7 +805,6 @@ void Engine::SetServerAddress(float elapsedTime) {
|
||||
HandlePlayerInput(elapsedTime);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
void Engine::DisplayPauseMenu(float elapsedTime) {
|
||||
@@ -1004,7 +1020,6 @@ void Engine::DisplayOptionsMenu() {
|
||||
glPushMatrix();
|
||||
|
||||
m_textureOptionsMenu.Bind();
|
||||
glLoadIdentity();
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0); glVertex2i(0, 0);
|
||||
glTexCoord2f(1, 0); glVertex2i(Width(), 0);
|
||||
@@ -1116,8 +1131,8 @@ void Engine::DisplayAudioMenu(float centerX, float centerY) {
|
||||
float principalTop = centerY + Height() * 0.2f;
|
||||
|
||||
DrawSliderBackground(centerX, centerY, minBar, maxBar, principalBottom, principalTop);
|
||||
DrawSlider(centerX, centerY, m_volPrincipal, minBar, maxBar, principalBottom, principalTop);
|
||||
DisplayBarPercentValue(centerX, centerY, percentPosX, principalBottom, minBar, maxBar, m_volPrincipal);
|
||||
DrawSlider(centerX, centerY, m_mainvolume, minBar, maxBar, principalBottom, principalTop);
|
||||
DisplayBarPercentValue(centerX, centerY, percentPosX, principalBottom, minBar, maxBar, m_mainvolume);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
@@ -1136,8 +1151,8 @@ void Engine::DisplayAudioMenu(float centerX, float centerY) {
|
||||
float musiqueTop = centerY + Height() * 0.075f;
|
||||
|
||||
DrawSliderBackground(centerX, centerY, minBar, maxBar, musiqueBottom, musiqueTop);
|
||||
DrawSlider(centerX, centerY, m_volMusique, minBar, maxBar, musiqueBottom, musiqueTop);
|
||||
DisplayBarPercentValue(centerX, centerY, percentPosX, musiqueBottom, minBar, maxBar, m_volMusique);
|
||||
DrawSlider(centerX, centerY, m_musicvolume, minBar, maxBar, musiqueBottom, musiqueTop);
|
||||
DisplayBarPercentValue(centerX, centerY, percentPosX, musiqueBottom, minBar, maxBar, m_musicvolume);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
@@ -1156,8 +1171,8 @@ void Engine::DisplayAudioMenu(float centerX, float centerY) {
|
||||
float effectsTop = centerY - Height() * 0.05f;
|
||||
|
||||
DrawSliderBackground(centerX, centerY, minBar, maxBar, effectsBottom, effectsTop);
|
||||
DrawSlider(centerX, centerY, m_volEffets, minBar, maxBar, effectsBottom, effectsTop);
|
||||
DisplayBarPercentValue(centerX, centerY, percentPosX, effectsBottom, minBar, maxBar, m_volEffets);
|
||||
DrawSlider(centerX, centerY, m_sfxvolume, minBar, maxBar, effectsBottom, effectsTop);
|
||||
DisplayBarPercentValue(centerX, centerY, percentPosX, effectsBottom, minBar, maxBar, m_sfxvolume);
|
||||
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
@@ -1175,10 +1190,10 @@ void Engine::DisplayGraphicsMenu(float centerX, float centerY) {
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0); glVertex2i(centerX - Width() * 0.16, centerY + Height() * 0.165);
|
||||
glTexCoord2f(1, 0); glVertex2i(centerX + Width() * 0.1, centerY + Height() * 0.165);
|
||||
glTexCoord2f(1, 1); glVertex2i(centerX + Width() * 0.1, centerY - Height() * 0.04);
|
||||
glTexCoord2f(0, 1); glVertex2i(centerX - Width() * 0.16, centerY - Height() * 0.04);
|
||||
glTexCoord2f(0, 0); glVertex2i(Width() * 0.34, Height() * 0.46);
|
||||
glTexCoord2f(1, 0); glVertex2i(Width() * 0.6, Height() * 0.46);
|
||||
glTexCoord2f(1, 1); glVertex2i(Width() * 0.6, Height() * 0.67);
|
||||
glTexCoord2f(0, 1); glVertex2i(Width() * 0.34, Height() * 0.67);
|
||||
glEnd();
|
||||
|
||||
glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
@@ -1244,6 +1259,7 @@ void Engine::DisplayGraphicsMenu(float centerX, float centerY) {
|
||||
|
||||
void Engine::Render(float elapsedTime) {
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
m_audio.CleanupSFX();
|
||||
|
||||
if (m_gamestate == GameState::SPLASH) {
|
||||
if (m_splashTime > 0.0f) {
|
||||
@@ -1281,6 +1297,11 @@ void Engine::Render(float elapsedTime) {
|
||||
m_gamestate = GameState::MAIN_MENU;
|
||||
}
|
||||
}
|
||||
else if (m_singleReady) {
|
||||
m_gamestate = GameState::PLAY;
|
||||
m_audio.ToggleMusicState(m_gamestate);
|
||||
m_startTime = std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1332,11 +1353,11 @@ void Engine::Render(float elapsedTime) {
|
||||
if (leftright)
|
||||
vstep = Vector3f(m_player.GetPosition().x + m_player.GetDirection().z, m_player.GetPosition().y - 1.7f, m_player.GetPosition().z + m_player.GetDirection().x);
|
||||
else vstep = Vector3f(m_player.GetPosition().x - m_player.GetDirection().z, m_player.GetPosition().y - 1.7f, m_player.GetPosition().z - m_player.GetDirection().x);
|
||||
m_audio.Create3DAudioObj(step, AUDIO_PATH "step.wav", vstep, m_player.GetVelocity(), false, .8f);
|
||||
m_audio.Create3DAudioObj(step, AUDIO_PATH "step.wav", vstep, m_player.GetVelocity(), false, m_sfxvolume);
|
||||
leftright = !leftright;
|
||||
break;
|
||||
case Player::Sound::FALL:
|
||||
m_audio.Create3DAudioObj(step, AUDIO_PATH "hit.wav", m_player.GetPosition(), m_player.GetVelocity(), false, 1.f);
|
||||
m_audio.Create3DAudioObj(step, AUDIO_PATH "hit.wav", m_player.GetPosition(), m_player.GetVelocity(), false, m_sfxvolume);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
@@ -1365,7 +1386,7 @@ void Engine::Render(float elapsedTime) {
|
||||
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);
|
||||
m_audio.Create3DAudioObj(m_powpow, AUDIO_PATH "pow.wav", m_player.GetPOV(), m_player.GetDirection() * 10, false, m_sfxvolume);
|
||||
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);
|
||||
@@ -1419,7 +1440,7 @@ void Engine::Render(float elapsedTime) {
|
||||
}
|
||||
static bool died = false;
|
||||
if ((m_player.GetPosition().y < -1.7f || m_player.AmIDead()) && !died) {
|
||||
m_audio.Create3DAudioObj(m_scream, AUDIO_PATH "scream.wav", m_player.GetPOV(), m_player.GetVelocity(), false, 1.f);
|
||||
m_audio.Create3DAudioObj(m_scream, AUDIO_PATH "scream.wav", m_player.GetPOV(), m_player.GetVelocity(), false, m_sfxvolume);
|
||||
died = true;
|
||||
}
|
||||
if (m_player.GetPosition().y < -21.f || died) {
|
||||
@@ -1542,7 +1563,7 @@ void Engine::Render(float elapsedTime) {
|
||||
RemotePlayer* rt = static_cast<RemotePlayer*>(m_players[out.id]);
|
||||
rt->Feed(out);
|
||||
if (rt->AmIDead()) {
|
||||
m_audio.Create3DAudioObj(m_scream, AUDIO_PATH "scream.wav", m_player.GetPOV(), m_player.GetVelocity(), false, 1.f);
|
||||
m_audio.Create3DAudioObj(m_scream, AUDIO_PATH "scream.wav", m_player.GetPOV(), m_player.GetVelocity(), false, m_sfxvolume);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1572,7 +1593,7 @@ void Engine::Render(float elapsedTime) {
|
||||
m_bullets[0] = bult;
|
||||
break;
|
||||
}
|
||||
m_audio.Create3DAudioObj(m_powpow, AUDIO_PATH "pow.wav", bull.pos, bull.dir, false, 1.f);
|
||||
m_audio.Create3DAudioObj(m_powpow, AUDIO_PATH "pow.wav", bull.pos, bull.dir, false, m_sfxvolume);
|
||||
}
|
||||
else SystemNotification("Bullet is kraput.");
|
||||
break;
|
||||
@@ -1631,8 +1652,8 @@ void Engine::DisplayGameplayMenu(float centerX, float centerY) {
|
||||
float sensibleTop = centerY + Height() * 0.2f;
|
||||
|
||||
DrawSliderBackground(centerX, centerY, minBar, maxBar, sensibleBottom, sensibleTop);
|
||||
DrawSlider(centerX, centerY, m_volSensible, minBar, maxBar, sensibleBottom, sensibleTop);
|
||||
DisplayBarPercentValue(centerX, centerY, percentPosX, sensibleBottom, minBar, maxBar, m_volSensible);
|
||||
DrawSlider(centerX, centerY, m_sensitivity, minBar, maxBar, sensibleBottom, sensibleTop);
|
||||
DisplayBarPercentValue(centerX, centerY, percentPosX, sensibleBottom, minBar, maxBar, m_sensitivity);
|
||||
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
@@ -1652,14 +1673,22 @@ void Engine::DisplayBarPercentValue(float centerX, float centerY, float posX, fl
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
|
||||
float percentage = (value / (maxVal - minVal)) * 100;
|
||||
if (m_selectedOption == 0) {
|
||||
if (value < 0.0f) {
|
||||
value = 0.0f;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (value < 0.1f) {
|
||||
value = 0.1f;
|
||||
}
|
||||
}
|
||||
|
||||
if (value > 1.0f) {
|
||||
value = 1.0f;
|
||||
}
|
||||
|
||||
if (percentage < 0.0f) {
|
||||
percentage = 0.0f;
|
||||
}
|
||||
else if (percentage > 100.0f) {
|
||||
percentage = 100.0f;
|
||||
}
|
||||
float percentage = value * 100;
|
||||
|
||||
m_textureFont.Bind();
|
||||
std::ostringstream ss;
|
||||
@@ -1673,19 +1702,31 @@ void Engine::DisplayBarPercentValue(float centerX, float centerY, float posX, fl
|
||||
}
|
||||
|
||||
void Engine::DrawSlider(float centerX, float centerY, float value, float minVal, float maxVal, float bottomSideValue, float topSideValue) {
|
||||
if (value < 0.0f) {
|
||||
value = 0.0f;
|
||||
float barLength = maxVal - minVal;
|
||||
|
||||
if (m_selectedOption == 0) {
|
||||
if (value < 0.0f) {
|
||||
value = 0.0f;
|
||||
}
|
||||
}
|
||||
else if (value > (maxVal - minVal)) {
|
||||
value = (maxVal - minVal);
|
||||
else {
|
||||
if (value < 0.1f) {
|
||||
value = 0.1f;
|
||||
}
|
||||
}
|
||||
|
||||
if (value >= 0.0f && value <= (maxVal - minVal)) {
|
||||
if (value > 1.0f) {
|
||||
value = 1.0f;
|
||||
}
|
||||
|
||||
float scaledLength = minVal + value * barLength;
|
||||
|
||||
if (value >= 0.0f && value <= 1.0f) {
|
||||
glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0); glVertex2i(minVal, bottomSideValue);
|
||||
glTexCoord2f(1, 0); glVertex2i(minVal + value, bottomSideValue);
|
||||
glTexCoord2f(1, 1); glVertex2i(minVal + value, topSideValue);
|
||||
glTexCoord2f(1, 0); glVertex2i(scaledLength, bottomSideValue);
|
||||
glTexCoord2f(1, 1); glVertex2i(scaledLength, topSideValue);
|
||||
glTexCoord2f(0, 1); glVertex2i(minVal, topSideValue);
|
||||
glEnd();
|
||||
}
|
||||
@@ -2070,9 +2111,16 @@ void Engine::HandlePlayerInput(float elapsedTime) {
|
||||
m_currentInputString.size() > 1 &&
|
||||
m_currentInputString.size() < 26) {
|
||||
m_username = m_currentInputString;
|
||||
m_player.SetUsername(m_username);
|
||||
m_currentInputString = "";
|
||||
m_settingUsername = false;
|
||||
m_settingServer = true;
|
||||
|
||||
if (m_selectedMultiPlayer) {
|
||||
m_settingServer = true;
|
||||
}
|
||||
else if (m_selectedSinglePlayer) {
|
||||
m_singleReady = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_settingServer) {
|
||||
@@ -2100,11 +2148,10 @@ void Engine::HandlePlayerInput(float elapsedTime) {
|
||||
PrintText(Width() * 0.6f, Height() * 0.4f, ss.str(), 2.0f);
|
||||
}
|
||||
|
||||
|
||||
void Engine::MouseMoveEvent(int x, int y) {
|
||||
if (m_gamestate == GameState::PLAY) {
|
||||
m_player.TurnLeftRight(x - (Width() / 2));
|
||||
m_player.TurnTopBottom(y - (Height() / 2));
|
||||
m_player.TurnLeftRight(x - (Width() / 2), m_sensitivity);
|
||||
m_player.TurnTopBottom(y - (Height() / 2), m_sensitivity);
|
||||
|
||||
// Centrer la souris seulement si elle n'est pas d<>j<EFBFBD> centr<74>e
|
||||
// Il est n<>cessaire de faire la v<>rification pour <20>viter de tomber
|
||||
@@ -2122,18 +2169,24 @@ void Engine::MouseMoveEvent(int x, int y) {
|
||||
float centerY = Height() * 0.5f;
|
||||
float leftBar = centerX - Width() * 0.15f;
|
||||
float rightBar = centerX + Width() * 0.3f;
|
||||
float barLength = rightBar - leftBar;
|
||||
|
||||
float normalizedPosition = (x - leftBar) / barLength;
|
||||
|
||||
if (m_selectedOption == 0 && m_selectedOptAudioMainBar) {
|
||||
m_volPrincipal = x - leftBar;
|
||||
m_mainvolume = normalizedPosition;
|
||||
m_audio.SetMainVolume(m_mainvolume);
|
||||
}
|
||||
else if (m_selectedOption == 0 && m_selectedOptAudioMusicBar) {
|
||||
m_volMusique = x - leftBar;
|
||||
m_musicvolume = normalizedPosition;
|
||||
m_audio.SetMusicVolume(m_musicvolume);
|
||||
}
|
||||
else if (m_selectedOption == 0 && m_selectedOptAudioSfxBar) {
|
||||
m_volEffets = x - leftBar;
|
||||
m_sfxvolume = normalizedPosition;
|
||||
m_audio.SetSfxVolume(m_sfxvolume);
|
||||
}
|
||||
else if (m_selectedOption == 2 && m_selectedGameplaySensitivityBar) {
|
||||
m_volSensible = x - leftBar;
|
||||
m_sensitivity = normalizedPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2179,19 +2232,23 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
|
||||
float bottomThird = centerY + Height() * 0.198f;
|
||||
|
||||
if (x > leftButton && x < rightButton && y > bottomFirst && y < topFirst) {
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav");
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume);
|
||||
if (m_selectedPlayOptions) {
|
||||
m_gamestate = GameState::PLAY;
|
||||
m_audio.ToggleMusicState(m_gamestate);
|
||||
m_gamestate = GameState::LOBBY;
|
||||
m_selectedSinglePlayer = true;
|
||||
m_selectedMultiPlayer = false;
|
||||
m_settingUsername = true;
|
||||
}
|
||||
else {
|
||||
m_selectedPlayOptions = true;
|
||||
}
|
||||
}
|
||||
else if (x > leftButton && x < rightButton && y > bottomSecond && y < topSecond) {
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav");
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume);
|
||||
if (m_selectedPlayOptions) {
|
||||
m_gamestate = GameState::LOBBY;
|
||||
m_selectedMultiPlayer = true;
|
||||
m_selectedSinglePlayer = false;
|
||||
m_settingUsername = true;
|
||||
}
|
||||
else {
|
||||
@@ -2199,7 +2256,7 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
|
||||
}
|
||||
}
|
||||
else if (x > leftButton && x < rightButton && y > bottomThird && y < topThird) {
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav");
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume);
|
||||
if (m_selectedPlayOptions) {
|
||||
m_selectedPlayOptions = false;
|
||||
}
|
||||
@@ -2230,25 +2287,26 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
|
||||
float bottomBack = centerY + Height() * 0.2f;
|
||||
|
||||
if (x > leftAudio && x < rightAudio && y > bottomAudio && y < topAudio) {
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav");
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume);
|
||||
m_selectedOption = 0; // Volume
|
||||
}
|
||||
else if (x > leftGraph && x < rightGraph && y > bottomGraph && y < topGraph) {
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav");
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume);
|
||||
m_selectedOption = 1; // Graphics
|
||||
}
|
||||
else if (x > leftGameplay && x < rightGameplay && y > bottomGameplay && y < topGameplay) {
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav");
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume);
|
||||
m_selectedOption = 2; // Gameplay
|
||||
}
|
||||
else if (x > leftBack && x < rightBack && y > bottomBack && y < topBack) {
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav");
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume);
|
||||
m_gamestate = GameState::MAIN_MENU;
|
||||
}
|
||||
|
||||
// Audio
|
||||
float leftBar = centerX - Width() * 0.15f;
|
||||
float rightBar = centerX + Width() * 0.3f;
|
||||
float barLength = rightBar - leftBar;
|
||||
|
||||
float topBarPrincipal = centerY - Height() * 0.165f;
|
||||
float bottomBarPrincipal = centerY - Height() * 0.2f;
|
||||
@@ -2259,20 +2317,25 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
|
||||
float topBarEffets = centerY + Height() * 0.085f;
|
||||
float bottomBarEffets = centerY + Height() * 0.05f;
|
||||
|
||||
float normalizedPosition = (x - leftBar) / barLength;
|
||||
|
||||
if (m_selectedOption == 0 && x > leftBar && x < rightBar && y > bottomBarPrincipal && y < topBarPrincipal) {
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav");
|
||||
m_volPrincipal = x - leftBar;
|
||||
m_selectedOptAudioMainBar = true;
|
||||
m_mainvolume = normalizedPosition;
|
||||
m_audio.SetMainVolume(m_mainvolume);
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume);
|
||||
}
|
||||
else if (m_selectedOption == 0 && x > leftBar && x < rightBar && y > bottomBarMusique && y < topBarMusique) {
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav");
|
||||
m_volMusique = x - leftBar;
|
||||
m_selectedOptAudioMusicBar = true;
|
||||
m_musicvolume = normalizedPosition;
|
||||
m_audio.SetMusicVolume(m_musicvolume);
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume);
|
||||
}
|
||||
else if (m_selectedOption == 0 && x > leftBar && x < rightBar && y > bottomBarEffets && y < topBarEffets) {
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav");
|
||||
m_volEffets = x - leftBar;
|
||||
m_selectedOptAudioSfxBar = true;
|
||||
m_sfxvolume = normalizedPosition;
|
||||
m_audio.SetSfxVolume(m_sfxvolume);
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume);
|
||||
}
|
||||
|
||||
// Resolution
|
||||
@@ -2291,28 +2354,38 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
|
||||
float topChkUHD = centerY + Height() * 0.025f;
|
||||
float bottomChkUHD = centerY;
|
||||
|
||||
if (m_selectedOption == 1 && leftChk && x < rightChk && y > bottomChkHD && y < topChkHD) {
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav");
|
||||
m_resolution = HD;
|
||||
if (m_selectedOption == 1) {
|
||||
if (x > leftChk && x < rightChk && y > bottomChkHD && y < topChkHD) {
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume);
|
||||
ChangeResolution(HD);
|
||||
}
|
||||
else if (x > leftChk && x < rightChk && y > bottomChkFHD && y < topChkFHD) {
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume);
|
||||
ChangeResolution(FHD);
|
||||
}
|
||||
else if (x > leftChk && x < rightChk && y > bottomChkQHD && y < topChkQHD) {
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume);
|
||||
ChangeResolution(QHD);
|
||||
}
|
||||
else if (x > leftChk && x < rightChk && y > bottomChkUHD && y < topChkUHD) {
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume);
|
||||
ChangeResolution(UHD);
|
||||
}
|
||||
}
|
||||
else if (m_selectedOption == 1 && x > leftChk && x < rightChk && y > bottomChkFHD && y < topChkFHD) {
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav");
|
||||
m_resolution = FHD;
|
||||
|
||||
if (normalizedPosition < 0.1f) {
|
||||
normalizedPosition = 0.1f;
|
||||
}
|
||||
else if (m_selectedOption == 1 && x > leftChk && x < rightChk && y > bottomChkQHD && y < topChkQHD) {
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav");
|
||||
m_resolution = QHD;
|
||||
}
|
||||
else if (m_selectedOption == 1 && x > leftChk && x < rightChk && y > bottomChkUHD && y < topChkUHD) {
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav");
|
||||
m_resolution = UHD;
|
||||
else if (normalizedPosition > 1.0f) {
|
||||
normalizedPosition = 1.0f;
|
||||
}
|
||||
|
||||
// Gameplay
|
||||
if (m_selectedOption == 2 && x > leftBar && x < rightBar && y > bottomBarPrincipal && y < topBarPrincipal) {
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav");
|
||||
m_volSensible = x - leftBar;
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume);
|
||||
m_selectedGameplaySensitivityBar = true;
|
||||
m_sensitivity = normalizedPosition;
|
||||
m_player.SetSensitivity(m_sensitivity);
|
||||
}
|
||||
}
|
||||
else if (m_gamestate == GameState::PAUSE) {
|
||||
@@ -2327,14 +2400,18 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
|
||||
float bottomMainMenu = centerY - Height() * 0.4415f;
|
||||
|
||||
if (x > leftResume && x < rightResume && y > bottomResume && y < topResume) {
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav");
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume);
|
||||
m_gamestate = GameState::PLAY;
|
||||
m_audio.ToggleMusicState(m_gamestate);
|
||||
}
|
||||
else if (x > leftMainMenu && x < rightMainMenu && y > bottomMainMenu && y < topMainMenu) {
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav");
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume);
|
||||
m_gamestate = GameState::MAIN_MENU;
|
||||
m_selectedPlayOptions = false;
|
||||
m_selectedSinglePlayer = false;
|
||||
m_selectedMultiPlayer = false;
|
||||
m_singleReady = false;
|
||||
m_multiReady = false;
|
||||
m_audio.ToggleMusicState(m_gamestate);
|
||||
if (m_networkgame) {
|
||||
if (m_conn.m_sock_udp)
|
||||
@@ -2344,11 +2421,62 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_gamestate == GameState::LOBBY) {
|
||||
float leftBack = centerX + Width() * 0.178f;
|
||||
float rightBack = centerX + Width() * 0.397f;
|
||||
float topBack = centerY + Height() * 0.346f;
|
||||
float bottomBack = centerY + Height() * 0.275f;
|
||||
|
||||
if (leftBack && x < rightBack && y > bottomBack && y < topBack) {
|
||||
m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume);
|
||||
m_gamestate = GameState::MAIN_MENU;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Engine::MouseReleaseEvent(const MOUSE_BUTTON& button, int x, int y) {
|
||||
float centerX = Width() * 0.5f;
|
||||
float centerY = Height() * 0.5f;
|
||||
float leftBar = centerX - Width() * 0.15f;
|
||||
float rightBar = centerX + Width() * 0.3f;
|
||||
float barLength = rightBar - leftBar;
|
||||
|
||||
float normalizedPosition = (x - leftBar) / barLength;
|
||||
|
||||
if (normalizedPosition > 1.0f) {
|
||||
normalizedPosition = 1.0f;
|
||||
}
|
||||
|
||||
switch (button) {
|
||||
case MOUSE_BUTTON_LEFT:
|
||||
if (m_selectedOption == 0) {
|
||||
if (normalizedPosition < 0.0f) {
|
||||
normalizedPosition = 0.0f;
|
||||
}
|
||||
|
||||
if (m_selectedOptAudioMainBar) {
|
||||
m_mainvolume = normalizedPosition;
|
||||
m_audio.SetMainVolume(m_mainvolume);
|
||||
}
|
||||
else if (m_selectedOptAudioMusicBar) {
|
||||
m_musicvolume = normalizedPosition;
|
||||
m_audio.SetMusicVolume(m_musicvolume);
|
||||
}
|
||||
else if (m_selectedOptAudioSfxBar) {
|
||||
m_sfxvolume = normalizedPosition;
|
||||
m_audio.SetSfxVolume(m_sfxvolume);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (m_selectedGameplaySensitivityBar) {
|
||||
if (normalizedPosition < 0.1f) {
|
||||
normalizedPosition = 0.1f;
|
||||
}
|
||||
|
||||
m_sensitivity = normalizedPosition;
|
||||
m_player.SetSensitivity(m_sensitivity);
|
||||
}
|
||||
}
|
||||
m_mouseL = false;
|
||||
m_block = false;
|
||||
m_selectedOptAudioMainBar = false;
|
||||
@@ -2386,4 +2514,29 @@ bool Engine::LoadTexture(Texture& texture, const std::string& filename, bool use
|
||||
return true;
|
||||
}
|
||||
|
||||
void Engine::ChangeResolution(Resolution resolution) {
|
||||
DeInit();
|
||||
|
||||
switch (resolution) {
|
||||
case HD:
|
||||
OpenglContext::InitWindow(1280, 720);
|
||||
m_resolution = HD;
|
||||
break;
|
||||
case FHD:
|
||||
OpenglContext::InitWindow(1920, 1080);
|
||||
m_resolution = FHD;
|
||||
break;
|
||||
case QHD:
|
||||
OpenglContext::InitWindow(2560, 1440);
|
||||
m_resolution = QHD;
|
||||
break;
|
||||
case UHD:
|
||||
OpenglContext::InitWindow(3840, 2160);
|
||||
m_resolution = UHD;
|
||||
break;
|
||||
}
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user