diff --git a/include/game/agame/player.hpp b/include/game/agame/player.hpp index eee6760..a816be4 100644 --- a/include/game/agame/player.hpp +++ b/include/game/agame/player.hpp @@ -21,5 +21,7 @@ GAME_ENTITY(Player) std::shared_ptr mGroundTex; bool mIsShipMode = true; float mShoreMargin = 40.f; + float mStateTransitionCooldown = 1.f; + float mStateTransitionCooldownTimer = 0.f; END_GAME_ENTITY() } \ No newline at end of file diff --git a/src/game/agame/player.cpp b/src/game/agame/player.cpp index 244bdce..7a2f5ef 100644 --- a/src/game/agame/player.cpp +++ b/src/game/agame/player.cpp @@ -99,7 +99,7 @@ namespace Game::AGame { setTexture(mGroundTex); } - LOG("Š: " << w << " V: " << h); + LOG("W: " << w << " H: " << h); //mSound.~Sound(); } @@ -109,13 +109,21 @@ namespace Game::AGame { //mTransform.scaleY = 1.f + 0.5f * std::cos(RUNNING_TIME() / 0.5f); // Pulsate scale for testing //Object::Camera::getInstance().move(1.f, 0.f); + if (mStateTransitionCooldownTimer > 0.f) { + mStateTransitionCooldownTimer -= deltaTime; + if (mStateTransitionCooldownTimer < 0.f) { + mStateTransitionCooldownTimer = 0.f; + } + } + const float landBoundaryX = Game::GameManager::getSharedData("terrainLandBoundaryX"); const float halfWidth = mTex->getWidth() * mTransform.adjustedScaleX() / 2.f; if (Input::isKeyPressed(SDL_SCANCODE_E)) { const bool nearShore = std::abs((mTransform.x + halfWidth) - landBoundaryX) <= mShoreMargin; - if (nearShore) { + if (nearShore && mStateTransitionCooldownTimer <= 0.f) { mIsShipMode = !mIsShipMode; + mStateTransitionCooldownTimer = mStateTransitionCooldown; } }