diff options
author | Vittorio Romeo <vittorio.romeo@outlook.com> | 2021-12-08 21:09:19 +0000 |
---|---|---|
committer | Vittorio Romeo <vittorio.romeo@outlook.com> | 2021-12-08 21:09:19 +0000 |
commit | cde964199443dfb92036d3ff9041142bc846e50f (patch) | |
tree | 04a1f06b33ff9ee3638d4b5436a707fbdeb1b67f | |
parent | 20877505bc0cd9cf77c0b11b0884bf4a322a11ce (diff) |
Fix death camera offset wrongreplace_deprecated_sfml_uses
-rw-r--r-- | include/SSVOpenHexagon/Core/HexagonGame.hpp | 4 | ||||
-rw-r--r-- | src/SSVOpenHexagon/Core/HGUpdate.cpp | 31 | ||||
-rw-r--r-- | src/SSVOpenHexagon/Core/HexagonGame.cpp | 4 |
3 files changed, 18 insertions, 21 deletions
diff --git a/include/SSVOpenHexagon/Core/HexagonGame.hpp b/include/SSVOpenHexagon/Core/HexagonGame.hpp index 9123e98e..4944d9c9 100644 --- a/include/SSVOpenHexagon/Core/HexagonGame.hpp +++ b/include/SSVOpenHexagon/Core/HexagonGame.hpp @@ -133,8 +133,8 @@ private: struct PreShakeCenters { - sf::Vector2f backgroundCameraPreShakeCenter; - sf::Vector2f overlayCameraPreShakeCenter; + sf::Vector2f background; + sf::Vector2f overlay; }; std::optional<PreShakeCenters> preShakeCenters; diff --git a/src/SSVOpenHexagon/Core/HGUpdate.cpp b/src/SSVOpenHexagon/Core/HGUpdate.cpp index 703e812f..83c9c713 100644 --- a/src/SSVOpenHexagon/Core/HGUpdate.cpp +++ b/src/SSVOpenHexagon/Core/HGUpdate.cpp @@ -826,28 +826,28 @@ void HexagonGame::updateRotation(ssvu::FT mFT) void HexagonGame::updateCameraShake(ssvu::FT mFT) { - if(!backgroundCamera.has_value() || !overlayCamera.has_value() || - status.cameraShake <= 0) + if(!backgroundCamera.has_value() || !overlayCamera.has_value()) { return; } - status.cameraShake -= mFT; - - if(!preShakeCenters.has_value()) + if(status.cameraShake <= 0.f) { - if(status.cameraShake <= 0) + if(preShakeCenters.has_value()) { - backgroundCamera->setCenter( - preShakeCenters->backgroundCameraPreShakeCenter); - - overlayCamera->setCenter( - preShakeCenters->overlayCameraPreShakeCenter); + backgroundCamera->setCenter(preShakeCenters->background); + overlayCamera->setCenter(preShakeCenters->overlay); preShakeCenters.reset(); - return; } + return; + } + + status.cameraShake -= mFT; + + if(!preShakeCenters.has_value()) + { preShakeCenters = PreShakeCenters{ backgroundCamera->getCenter(), overlayCamera->getCenter()}; } @@ -862,11 +862,8 @@ void HexagonGame::updateCameraShake(ssvu::FT mFT) return sf::Vector2f(rng.get_real(-i, i), rng.get_real(-i, i)); }; - backgroundCamera->setCenter( - preShakeCenters->backgroundCameraPreShakeCenter + makeShakeVec()); - - overlayCamera->setCenter( - preShakeCenters->overlayCameraPreShakeCenter + makeShakeVec()); + backgroundCamera->setCenter(preShakeCenters->background + makeShakeVec()); + overlayCamera->setCenter(preShakeCenters->overlay + makeShakeVec()); } void HexagonGame::updateFlash(ssvu::FT mFT) diff --git a/src/SSVOpenHexagon/Core/HexagonGame.cpp b/src/SSVOpenHexagon/Core/HexagonGame.cpp index f74748e6..18a022ed 100644 --- a/src/SSVOpenHexagon/Core/HexagonGame.cpp +++ b/src/SSVOpenHexagon/Core/HexagonGame.cpp @@ -317,7 +317,6 @@ HexagonGame::HexagonGame(Steam::steam_manager* mSteamManager, txSmallCircle = &assets.getTextureOrNullTexture("smallCircle.png"); } - game.onUpdate += [this](ssvu::FT mFT) { update(mFT, Config::getTimescale()); }; @@ -441,7 +440,8 @@ HexagonGame::HexagonGame(Steam::steam_manager* mSteamManager, Config::loadAllJoystickBinds(); // ------------------------------------------------------------------------ - // key icons + // Key icons + initKeyIcons(); } |