diff options
Diffstat (limited to '')
| -rw-r--r-- | platformer/src/camera.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/platformer/src/camera.c b/platformer/src/camera.c index 4511d47..7663003 100644 --- a/platformer/src/camera.c +++ b/platformer/src/camera.c @@ -73,7 +73,7 @@ * countdown and stops the tilt at once, and a pitch you set by hand is * respected until the countdown runs out again. * - * - camera_update(c, in, follow_point, follow_facing, aspect, dt): + * - camera_update(c, in, follow_point, follow_facing, pan_locked, aspect, dt): * 1. Movement check: the subject counts as "moving" if it changed since * last tick (this includes slowing to a stop and jumping in place). * On recenter_pressed, start a recenter (see above). @@ -83,9 +83,11 @@ * so the player stays at the same screen spot while orbiting. While * recentering, apply the same yaw change to recenter_yaw, then ease yaw * toward recenter_yaw (the short way around) at CAMERA_RECENTER_RATE. - * Otherwise, while moving, apply the back-quarter swing: approach its - * goal yaw at CAMERA_SWING_SPEED * |lateral share| rad/s (constant rate, - * so the swing is slow and even). Then apply the auto-pitch (see + * Otherwise, while moving and NOT pan_locked, apply the back-quarter + * swing: approach its goal yaw at CAMERA_SWING_SPEED * |lateral share| + * rad/s (constant rate, so the swing is slow and even). In a + * locked-pan zone the camera never turns behind the player on its + * own; everything else below still applies. Then apply the auto-pitch (see * above). Framing is kept through all of these. * 3. Hold still (except while recentering): the camera does NOT follow * vertically or in depth by default. Project how far the subject moved @@ -395,7 +397,7 @@ void camera_init(Camera *c, Vec3 follow_point) } void camera_update(Camera *c, const Input *in, Vec3 follow_point, float follow_facing, - float aspect, float dt) + bool pan_locked, float aspect, float dt) { /* 1. Did the player move since last tick? And start a recenter glide * toward the shot from behind the player (opposite their facing). */ @@ -410,8 +412,9 @@ void camera_update(Camera *c, const Input *in, Vec3 follow_point, float follow_f /* 2. Orbit around the player. Mid-recenter, the stick turns the glide's * goal along with the view, so the two never fight. Otherwise a - * sideways run slowly swings the camera toward the back quarter. After - * a while hands-off, the pitch also tilts to its preferred angle. */ + * sideways run slowly swings the camera toward the back quarter, + * except in a locked-pan zone. After a while hands-off, the pitch also + * tilts to its preferred angle (in a locked-pan zone too). */ float yaw_before = c->yaw; orbit(c, in, dt); float lateral = 0.0f; /* sideways effects are off during a recenter glide */ @@ -420,7 +423,7 @@ void camera_update(Camera *c, const Input *in, Vec3 follow_point, float follow_f if (c->recentering) { c->recenter_yaw = wrap_angle(c->recenter_yaw + wrap_angle(c->yaw - yaw_before)); c->yaw = ease_toward_angle(c->yaw, c->recenter_yaw, CAMERA_RECENTER_RATE, dt); - } else { + } else if (!pan_locked) { swing_toward_back_quarter(c, moved_by, lateral, dt); } auto_pitch(c, in, dt); |
