This commit is contained in:
2026-05-02 22:27:00 +02:00
parent c46443e2f4
commit d9769bdbbb
2 changed files with 12 additions and 2 deletions

View File

@@ -21,5 +21,7 @@ GAME_ENTITY(Player)
std::shared_ptr<Game::Renderer::Texture> mGroundTex; std::shared_ptr<Game::Renderer::Texture> mGroundTex;
bool mIsShipMode = true; bool mIsShipMode = true;
float mShoreMargin = 40.f; float mShoreMargin = 40.f;
float mStateTransitionCooldown = 1.f;
float mStateTransitionCooldownTimer = 0.f;
END_GAME_ENTITY() END_GAME_ENTITY()
} }

View File

@@ -99,7 +99,7 @@ namespace Game::AGame {
setTexture(mGroundTex); setTexture(mGroundTex);
} }
LOG("Š: " << w << " V: " << h); LOG("W: " << w << " H: " << h);
//mSound.~Sound(); //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 //mTransform.scaleY = 1.f + 0.5f * std::cos(RUNNING_TIME() / 0.5f); // Pulsate scale for testing
//Object::Camera::getInstance().move(1.f, 0.f); //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<float>("terrainLandBoundaryX"); const float landBoundaryX = Game::GameManager::getSharedData<float>("terrainLandBoundaryX");
const float halfWidth = mTex->getWidth() * mTransform.adjustedScaleX() / 2.f; const float halfWidth = mTex->getWidth() * mTransform.adjustedScaleX() / 2.f;
if (Input::isKeyPressed(SDL_SCANCODE_E)) { if (Input::isKeyPressed(SDL_SCANCODE_E)) {
const bool nearShore = std::abs((mTransform.x + halfWidth) - landBoundaryX) <= mShoreMargin; const bool nearShore = std::abs((mTransform.x + halfWidth) - landBoundaryX) <= mShoreMargin;
if (nearShore) { if (nearShore && mStateTransitionCooldownTimer <= 0.f) {
mIsShipMode = !mIsShipMode; mIsShipMode = !mIsShipMode;
mStateTransitionCooldownTimer = mStateTransitionCooldown;
} }
} }