Strafing now works, thanks to rcr but needs a unit test on the camera and probbably a refactor so that rayview uses it or knows nothing about it?

This commit is contained in:
Zed A. Shaw 2025-02-03 14:17:20 -05:00
parent 48ac6603a8
commit 740e30cb2b
3 changed files with 40 additions and 9 deletions

View file

@ -38,3 +38,17 @@ bool CameraLOL::play_rotate(Raycaster &rayview) {
return t > 1.0;
}
void CameraLOL::plan_strafe(Raycaster &rayview, int dir) {
t = 0.0;
targetX = rayview.$posX + int(-rayview.$dirY * 1.5 * dir);
targetY = rayview.$posY + int(rayview.$dirX * 1.5 * dir);
}
bool CameraLOL::play_strafe(Raycaster &rayview) {
t += moveSpeed;
rayview.$posX = std::lerp(rayview.$posX, targetX, t);
rayview.$posY = std::lerp(rayview.$posY, targetY, t);
return t >= 1.0;
}