Add configuration option for ghost reset distance. Improve documentation.

This commit is contained in:
2025-12-20 17:12:58 -05:00
parent faf3f239d8
commit 7a3705d342
25 changed files with 132 additions and 28 deletions

View File

@@ -33,7 +33,7 @@ Ghost::Ghost(float xmin, float xmax, float zmin, float zmax) {
void Ghost::apply_movement(float curr_time, float timed) {
// vertical movement
// Bob vertically to make ghosts feel more alive.
pos.y = 2.5 + sin(curr_time + y_offset);
moved.x = -sin(yawr) + cos(yawr);
@@ -77,7 +77,7 @@ glm::mat4 Ghost::get_model(glm::vec3 &camera_pos) {
// apply direction
// the cross product helps us determine which direction it's going relative to player
glm::vec3 ghost_to_player = pos - camera_pos;
glm::vec3 crossed = glm::cross(ghost_to_player, moved);
glm::vec3 crossed = glm::cross(ghost_to_player, moved); // determines whether the sprite should face left/right
//float dist2 = ghost_to_player.x * ghost_to_player.x + ghost_to_player.z * ghost_to_player.z;
float theta = atan2f(ghost_to_player.x, ghost_to_player.z);
if (crossed.y < 0.0) {
@@ -113,9 +113,8 @@ glm::vec3 Ghost::get_pos() const {
}
void Ghost::reverse_direction_from_position(glm::vec3 target_pos) {
// Calculate direction from target_pos to ghost position
// Push the ghost to flee from target_pos (usually the starting area).
glm::vec3 direction = pos - target_pos;
// Set yawr to point directly away from target_pos
yawr = atan2(direction.x, direction.z);
}