Add one-time spawn camera pan

This commit is contained in:
Kelsi 2026-02-05 18:06:52 -08:00
parent 8bd60c3320
commit 5401683a8d
5 changed files with 81 additions and 7 deletions

View file

@ -56,6 +56,17 @@ CameraController::CameraController(Camera* cam) : camera(cam) {
reset();
}
void CameraController::startIntroPan(float durationSec, float orbitDegrees) {
if (!camera) return;
introActive = true;
introTimer = 0.0f;
introDuration = std::max(0.5f, durationSec);
introStartYaw = yaw;
introOrbitDegrees = orbitDegrees;
introPitch = pitch;
thirdPerson = true;
}
void CameraController::update(float deltaTime) {
if (!enabled || !camera) {
return;
@ -77,6 +88,24 @@ void CameraController::update(float deltaTime) {
bool ctrlDown = !uiWantsKeyboard && (input.isKeyPressed(SDL_SCANCODE_LCTRL) || input.isKeyPressed(SDL_SCANCODE_RCTRL));
bool nowJump = !uiWantsKeyboard && !sitting && input.isKeyPressed(SDL_SCANCODE_SPACE);
if (introActive) {
if (leftMouseDown || rightMouseDown || keyW || keyS || keyA || keyD || keyQ || keyE || nowJump) {
introActive = false;
} else {
introTimer += deltaTime;
float t = (introDuration > 0.0f) ? std::min(introTimer / introDuration, 1.0f) : 1.0f;
yaw = introStartYaw + introOrbitDegrees * t;
pitch = introPitch;
camera->setRotation(yaw, pitch);
facingYaw = yaw;
if (t >= 1.0f) {
introActive = false;
}
}
// Suppress player movement/input during intro.
keyW = keyS = keyA = keyD = keyQ = keyE = nowJump = false;
}
bool mouseAutorun = !uiWantsKeyboard && !sitting && leftMouseDown && rightMouseDown;
bool nowForward = keyW || mouseAutorun;
bool nowBackward = keyS;
@ -959,6 +988,9 @@ void CameraController::processMouseMotion(const SDL_MouseMotionEvent& event) {
if (!enabled || !camera) {
return;
}
if (introActive) {
return;
}
if (!mouseButtonDown) {
return;