dodatna logika

This commit is contained in:
2026-05-02 18:09:17 +02:00
parent 56d567b77d
commit e4389f035d
16 changed files with 239 additions and 37 deletions

View File

@@ -126,6 +126,21 @@ namespace Game::AGame {
if (Input::isKeyPressed(SDL_SCANCODE_D)) { mTransform.x += mSpeed * deltaTime; mIsFlipped = true; }
mSpeed = Input::isKeyPressed(SDL_SCANCODE_LSHIFT) ? 400.f : 200.f;
int w = 0;
int h = 0;
SDL_GetWindowSizeInPixels(Window::Window::getSDLWindowBackend(), &w, &h);
const float entityWidth = mTex ? mTex->getWidth() * mTransform.adjustedScaleX() : 0.f;
const float entityHeight = mTex ? mTex->getHeight() * mTransform.adjustedScaleY() : 0.f;
const float minX = -w / 2.f;
const float maxX = w / 2.f - entityWidth;
const float minY = -h / 2.f;
const float maxY = h / 2.f - entityHeight;
if (mTransform.x < minX) mTransform.x = minX;
if (mTransform.x > maxX) mTransform.x = maxX;
if (mTransform.y < minY) mTransform.y = minY;
if (mTransform.y > maxY) mTransform.y = maxY;
if (mIsShipMode && (mTransform.x + halfWidth) < landBoundaryX + mShoreMargin) {
mTransform.x = landBoundaryX + mShoreMargin - halfWidth;
}