Lots of dumb little edits to sort out what I'm aiming at. I'll next clean out most of this in a refactor.

This commit is contained in:
Zed A. Shaw 2025-04-06 15:32:19 -04:00
parent 1f90367f51
commit c7c48658bd
13 changed files with 60 additions and 29 deletions

View file

@ -2,7 +2,7 @@
#include <numbers>
#include <cmath>
Point CameraLOL::plan_move(Raycaster &rayview, int dir, bool strafe) {
Point CameraLOL::plan_move(int dir, bool strafe) {
t = 0.0;
if(strafe) {
target_x = rayview.$pos_x + int(-rayview.$dir_y * 1.5 * dir);
@ -15,7 +15,7 @@ Point CameraLOL::plan_move(Raycaster &rayview, int dir, bool strafe) {
return {size_t(target_x), size_t(target_y)};
}
void CameraLOL::plan_rotate(Raycaster &rayview, int dir) {
void CameraLOL::plan_rotate(int dir) {
t = 0.0;
double angle_dir = std::numbers::pi * 0.25 * dir;
@ -26,24 +26,31 @@ void CameraLOL::plan_rotate(Raycaster &rayview, int dir) {
target_plane_y = rayview.$plane_x * sin(angle_dir) + rayview.$plane_y * cos(angle_dir);
}
bool CameraLOL::play_rotate(Raycaster &rayview) {
bool CameraLOL::play_rotate() {
t += rot_speed;
rayview.$dir_x = std::lerp(rayview.$dir_x, target_dir_x, t);
rayview.$dir_y = std::lerp(rayview.$dir_y, target_dir_y, t);
rayview.$plane_x = std::lerp(rayview.$plane_x, target_plane_x, t);
rayview.$plane_y = std::lerp(rayview.$plane_y, target_plane_y, t);
return t > 1.0;
return t >= 1.0;
}
bool CameraLOL::play_move(Raycaster &rayview) {
bool CameraLOL::play_move() {
t += move_speed;
rayview.$pos_x = std::lerp(rayview.$pos_x, target_x, t);
rayview.$pos_y = std::lerp(rayview.$pos_y, target_y, t);
return t >= 1.0;
}
void CameraLOL::abort_plan(Raycaster& rayview) {
void CameraLOL::abort_plan() {
target_x = rayview.$pos_x;
target_y = rayview.$pos_y;
}
Point CameraLOL::aimed_at() {
return {
size_t(rayview.$pos_x + rayview.$dir_x),
size_t(rayview.$pos_y + rayview.$dir_y)
};
}