diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2025-01-08 10:08:03 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2025-01-08 10:08:03 +0100 |
commit | 7f7c5c56dce30d47c32fb57fad6d839d0990b054 (patch) | |
tree | eebc8d3f4c332d969f4a66a566edd844bd43387c /game/enemy/EnemyScript.h | |
parent | ceb41b7ae7e2734af954364b319fc0b6f2a86c2f (diff) |
enemy spawn working + enemy shooting
Diffstat (limited to 'game/enemy/EnemyScript.h')
-rw-r--r-- | game/enemy/EnemyScript.h | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/game/enemy/EnemyScript.h b/game/enemy/EnemyScript.h index 0ecf050..35d2626 100644 --- a/game/enemy/EnemyScript.h +++ b/game/enemy/EnemyScript.h @@ -1,7 +1,30 @@ #pragma once - +#include <crepe/api/Event.h> +#include <crepe/api/Script.h> +#include <crepe/api/Event.h> +#include <crepe/api/Camera.h> +#include <random> +#include <chrono> +struct SpawnEnemyEvent : public crepe::Event{ + float speed = 0; + int column = 0; +}; class EnemyScript : public crepe::Script { + public: + EnemyScript(); void init() override; - void update() override; - void onCollide(const CollisionEvent & collisionData); + void fixed_update(crepe::duration_t dt) override; + void shoot(const crepe::vec2& position,float angle); + void onCollide(const crepe::CollisionEvent & collisionData); + bool spawn_enemy(const SpawnEnemyEvent& e); + private: + std::random_device rd; + std::default_random_engine engine; + + float speed = 50; + const float MIN_SPEED = 10; + const float MAX_SPEED = 130; + const float MAX_DISTANCE = 100; + std::chrono::time_point<std::chrono::steady_clock> last_fired; + std::chrono::duration<float> shot_delay; }; |