Skip to content

Commit

Permalink
tr1/camera: simplify bounce control
Browse files Browse the repository at this point in the history
This neatens the bounce control in the TR1 camera, similar to TR2.
  • Loading branch information
lahm86 committed Feb 28, 2025
1 parent 798dc16 commit 3ece4b7
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions src/tr1/game/camera/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,24 +321,23 @@ static void M_Move(const GAME_VECTOR *const ideal, const int32_t speed)
height = ceiling;
}

if (g_Camera.bounce) {
if (g_Camera.bounce > 0) {
g_Camera.pos.y += g_Camera.bounce;
g_Camera.target.y += g_Camera.bounce;
g_Camera.bounce = 0;
} else {
int32_t shake;
shake = (Random_GetControl() - 0x4000) * g_Camera.bounce / 0x7FFF;
g_Camera.pos.x += shake;
g_Camera.target.y += shake;
shake = (Random_GetControl() - 0x4000) * g_Camera.bounce / 0x7FFF;
g_Camera.pos.y += shake;
g_Camera.target.y += shake;
shake = (Random_GetControl() - 0x4000) * g_Camera.bounce / 0x7FFF;
g_Camera.pos.z += shake;
g_Camera.target.z += shake;
g_Camera.bounce += 5;
}
if (g_Camera.bounce > 0) {
g_Camera.pos.y += g_Camera.bounce;
g_Camera.target.y += g_Camera.bounce;
g_Camera.bounce = 0;
} else if (g_Camera.bounce < 0) {
const XYZ_32 shake = {
.x = g_Camera.bounce * (Random_GetControl() - 0x4000) / 0x7FFF,
.y = g_Camera.bounce * (Random_GetControl() - 0x4000) / 0x7FFF,
.z = g_Camera.bounce * (Random_GetControl() - 0x4000) / 0x7FFF,
};
g_Camera.pos.x += shake.x;
g_Camera.pos.y += shake.y;
g_Camera.pos.z += shake.z;
g_Camera.target.y += shake.x;
g_Camera.target.y += shake.y;
g_Camera.target.z += shake.z;
g_Camera.bounce += 5;
}

if (g_Camera.pos.y > height) {
Expand Down

0 comments on commit 3ece4b7

Please sign in to comment.