diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2025-01-08 12:47:28 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2025-01-08 12:47:28 +0100 |
commit | 5dc1a71ee3be5f72cdce0a2fdef21f4b46955557 (patch) | |
tree | 3939e332fea6e2fc201c742e972b1b45415055f0 /game/enemy | |
parent | 016b36b6d340be958bb047ca5f26dd54aa658c88 (diff) |
random better implemented
Diffstat (limited to 'game/enemy')
-rw-r--r-- | game/enemy/EnemyBulletSubScene.cpp | 1 | ||||
-rw-r--r-- | game/enemy/EnemyScript.cpp | 4 |
2 files changed, 3 insertions, 2 deletions
diff --git a/game/enemy/EnemyBulletSubScene.cpp b/game/enemy/EnemyBulletSubScene.cpp index dd79678..96ea7de 100644 --- a/game/enemy/EnemyBulletSubScene.cpp +++ b/game/enemy/EnemyBulletSubScene.cpp @@ -15,6 +15,7 @@ #include "EnemyBulletSubScene.h" #include "EnemyScript.h" #include "EnemyBulletScript.h" +#include "../Random.h" using namespace crepe; using namespace std; int EnemyBulletSubScene::create(Scene & scn){ diff --git a/game/enemy/EnemyScript.cpp b/game/enemy/EnemyScript.cpp index f9b79ea..0494bbc 100644 --- a/game/enemy/EnemyScript.cpp +++ b/game/enemy/EnemyScript.cpp @@ -15,7 +15,7 @@ using namespace std; EnemyScript::EnemyScript(){ engine.seed(rd()); this->last_fired = std::chrono::steady_clock::now(); - this->shot_delay = std::chrono::duration<float>(3 + Random::f(0,1)); + this->shot_delay = std::chrono::duration<float>(3 + Random::f(1,0)); } void EnemyScript::init(){ Metadata& meta = this->get_component<Metadata>(); @@ -52,7 +52,7 @@ void EnemyScript::fixed_update(duration_t dt) { if (elapsed > shot_delay) { this->shoot(transform.position,0); last_fired = now; - this->shot_delay = std::chrono::duration<float>(Random::f(1,4)); + this->shot_delay = std::chrono::duration<float>(Random::f(4,1)); } } |