I'm tired

This commit is contained in:
Rendo 2026-03-15 01:05:05 +05:00
commit a5882211a9
2 changed files with 14 additions and 4 deletions

View file

@ -79,7 +79,7 @@ class Ghost : public Entity {
Vector2 start_position; Vector2 start_position;
int respawn_timer = 0; int respawn_timer = 0;
void recalculate_direction(); void recalculate_direction();
void try_to_chase(); void try_switch_direction();
public: public:
Ghost(); Ghost();
void ready() override; void ready() override;

View file

@ -30,7 +30,6 @@ void Ghost::ready() {
} }
void Ghost::tick() { void Ghost::tick() {
try_to_chase();
Vector2 check_position = project_position(direction, 1); Vector2 check_position = project_position(direction, 1);
World& world = get_world(); World& world = get_world();
@ -46,10 +45,21 @@ void Ghost::tick() {
} }
position = check_position; position = check_position;
try_switch_direction();
} }
void Ghost::try_to_chase(){ void Ghost::try_switch_direction(){
// Todo /*if(rand()%10!=0)
return;
World world = get_world();
if(dynamic_cast<GhostWall*>(world.grid[world.indexify_position(project_position((direction+1)%4, 1))]) == nullptr){
direction = (direction+1)%4;
}
else if(dynamic_cast<GhostWall*>(world.grid[world.indexify_position(project_position((direction-1)%4,1))]) == nullptr){
direction = (direction-1)%4;
}*/
} }
void Ghost::recalculate_direction(){ void Ghost::recalculate_direction(){