From a5882211a9bd86d686e252bd9a3ee326a45cf482 Mon Sep 17 00:00:00 2001 From: Rendo Date: Sun, 15 Mar 2026 01:05:05 +0500 Subject: [PATCH] I'm tired --- src/components.h | 2 +- src/ghost.cpp | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/components.h b/src/components.h index ad633d7..a206b05 100644 --- a/src/components.h +++ b/src/components.h @@ -79,7 +79,7 @@ class Ghost : public Entity { Vector2 start_position; int respawn_timer = 0; void recalculate_direction(); - void try_to_chase(); + void try_switch_direction(); public: Ghost(); void ready() override; diff --git a/src/ghost.cpp b/src/ghost.cpp index f23e4b5..a52749e 100644 --- a/src/ghost.cpp +++ b/src/ghost.cpp @@ -30,7 +30,6 @@ void Ghost::ready() { } void Ghost::tick() { - try_to_chase(); Vector2 check_position = project_position(direction, 1); World& world = get_world(); @@ -46,10 +45,21 @@ void Ghost::tick() { } position = check_position; + try_switch_direction(); } -void Ghost::try_to_chase(){ - // Todo +void Ghost::try_switch_direction(){ + /*if(rand()%10!=0) + return; + + World world = get_world(); + + if(dynamic_cast(world.grid[world.indexify_position(project_position((direction+1)%4, 1))]) == nullptr){ + direction = (direction+1)%4; + } + else if(dynamic_cast(world.grid[world.indexify_position(project_position((direction-1)%4,1))]) == nullptr){ + direction = (direction-1)%4; + }*/ } void Ghost::recalculate_direction(){