diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2025-01-09 14:50:28 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2025-01-09 14:50:28 +0100 |
commit | c1f7b409bd6c883f7e9ff0f81afd3bee47469bdd (patch) | |
tree | 6121e5a60a02af3dca226d74ad381b856a0b8ae7 /game/enemy/EnemyScript.cpp | |
parent | 00f48f0b3ea0853d5277caef3fed6cff0042c607 (diff) |
removed iostream
Diffstat (limited to 'game/enemy/EnemyScript.cpp')
-rw-r--r-- | game/enemy/EnemyScript.cpp | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/game/enemy/EnemyScript.cpp b/game/enemy/EnemyScript.cpp index 04d577a..2382847 100644 --- a/game/enemy/EnemyScript.cpp +++ b/game/enemy/EnemyScript.cpp @@ -2,7 +2,6 @@ #include "../Config.h" #include "../Random.h" #include "EnemyConfig.h" -#include <iostream> #include <crepe/api/AI.h> #include <crepe/api/Animator.h> #include <crepe/api/AudioSource.h> @@ -42,17 +41,14 @@ void EnemyScript::fixed_update(duration_t dt) { Rigidbody & enemy_body = this->get_component<Rigidbody>(); AI & ai_component = this->get_component<AI>(); - //transform.position += enemy_body.data.linear_velocity * dt.count(); float direction_to_player_y = player_transform.position.y - transform.position.y; float distance_to_player_y = std::abs(direction_to_player_y); float adjustment_speed = speed * (distance_to_player_y / MAX_DISTANCE); - //cout << "before clamp speed: " << adjustment_speed << endl; adjustment_speed = std::clamp(adjustment_speed, MIN_SPEED, MAX_SPEED); - // Move the path nodes on the Y-axis - //cout << "adjusted_speed: " << adjustment_speed << endl; Rigidbody& player_body = this->get_components_by_tag<Rigidbody>("player").front(); + // move path nodes for (vec2 & path_node : ai_component.path) { path_node.y += (direction_to_player_y > 0 ? 1 : -1) * adjustment_speed * dt.count(); path_node.x += player_body.data.linear_velocity.x * dt.count(); |