Push sensibilite souris fonctionnelle.

This commit is contained in:
mduval76 2023-12-13 17:50:15 -05:00
parent 6ba316aa2d
commit 0b4546eee9

View File

@ -2307,10 +2307,18 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
m_resolution = UHD; m_resolution = UHD;
} }
if (normalizedPosition < 0.1f) {
normalizedPosition = 0.1f;
}
else if (normalizedPosition > 1.0f) {
normalizedPosition = 1.0f;
}
// Gameplay // Gameplay
if (m_selectedOption == 2 && x > leftBar && x < rightBar && y > bottomBarPrincipal && y < topBarPrincipal) { if (m_selectedOption == 2 && x > leftBar && x < rightBar && y > bottomBarPrincipal && y < topBarPrincipal) {
m_sensitivity = normalizedPosition; m_sensitivity = normalizedPosition;
std::cout << "Sensitivity PRESS: " << m_sensitivity << std::endl;
m_selectedGameplaySensitivityBar = true; m_selectedGameplaySensitivityBar = true;
m_player.SetSensitivity(m_sensitivity);
} }
} }
else if (m_gamestate == GameState::PAUSE) { else if (m_gamestate == GameState::PAUSE) {
@ -2336,8 +2344,26 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
} }
void Engine::MouseReleaseEvent(const MOUSE_BUTTON& button, int x, int y) { 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;
switch (button) { switch (button) {
case MOUSE_BUTTON_LEFT: case MOUSE_BUTTON_LEFT:
if (m_selectedGameplaySensitivityBar) {
float normalizedPosition = (x - leftBar) / barLength;
if (normalizedPosition < 0.1f) {
normalizedPosition = 0.1f;
}
else if (normalizedPosition > 1.0f) {
normalizedPosition = 1.0f;
}
m_sensitivity = normalizedPosition;
std::cout << "Sensitivity RELEASE: " << m_sensitivity << std::endl;
m_player.SetSensitivity(m_sensitivity);
}
m_mouseL = false; m_mouseL = false;
m_block = false; m_block = false;
m_selectedOptAudioMainBar = false; m_selectedOptAudioMainBar = false;