diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2025-01-08 10:47:47 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2025-01-08 10:47:47 +0100 |
commit | 65cdd7966c276dd7b1ffec7bf0de243b9370eeb1 (patch) | |
tree | 938c6ed098f2141a6a5c2d56146325938ae868bd /game/coins/CoinSystemScript.h | |
parent | 6112da75f973b1099fa95fcd9d3113c00302f5b4 (diff) | |
parent | ad5fb53986fcc3f3b3c5369574e0f8e95051f3d9 (diff) |
Merge branch 'master' of https://github.com/lonkaars/crepe into wouter/enemyAI
Diffstat (limited to 'game/coins/CoinSystemScript.h')
-rw-r--r-- | game/coins/CoinSystemScript.h | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/game/coins/CoinSystemScript.h b/game/coins/CoinSystemScript.h new file mode 100644 index 0000000..5c94273 --- /dev/null +++ b/game/coins/CoinSystemScript.h @@ -0,0 +1,107 @@ +#pragma once + +#include <random> +#include <string> + +#include <crepe/api/CircleCollider.h> +#include <crepe/api/Script.h> +#include <crepe/api/Sprite.h> +#include <crepe/api/Transform.h> +#include <crepe/types.h> + +class CoinSystemScript : public crepe::Script { +private: + struct CoinData { + crepe::vec2 start_location = {0, 0}; + std::string name = ""; + bool active = false; + CoinData(crepe::vec2 start_location) + : start_location(start_location), + name(""), + active(false) {} + }; + +public: + CoinSystemScript() {}; + void init() override; + void frame_update(crepe::duration_t dt) override; + +private: + void add_location(const crepe::vec2 & location); + void despawn_coins(); + void spawn_coins(); + void generate_locations(); + float preset_1(const crepe::vec2 & begin_position); + float preset_2(const crepe::vec2 & begin_position); + float preset_3(const crepe::vec2 & begin_position); + float preset_4(const crepe::vec2 & begin_position); + float preset_5(const crepe::vec2 & begin_position); + +private: + std::vector<std::function<float(const crepe::vec2 &)>> functions + = {[this](const crepe::vec2 & pos) { return preset_1(pos); }, + [this](const crepe::vec2 & pos) { return preset_2(pos); }, + [this](const crepe::vec2 & pos) { return preset_3(pos); }, + [this](const crepe::vec2 & pos) { return preset_4(pos); }, + [this](const crepe::vec2 & pos) { return preset_5(pos); }}; + std::vector<int> weights = {20, 20, 20, 20, 20}; + std::random_device rd; + std::default_random_engine engine; + float system_position = 1400; + static constexpr float SYSTEM_POSITION_OFFSET = 200; + +private: + static constexpr float SPAWN_SPACING_MIN = 400; + static constexpr float SPAWN_SPACING_MAX = 1000; + static constexpr float SPAWN_DISTANCE = 600; + static constexpr float DESPAWN_DISTANCE = 600; + static constexpr float SPAWN_AREA = 50; + std::vector<CoinData> coin_locations; + +private: + // preset one settings + // ***** ***** + // + // + // + // ***** ***** + static constexpr float ROW_OFFSET_1 = 100; + static constexpr float COLUM_OFFSET_1 = 25; + static constexpr int COLUM_AMOUNT_1 = 5; + +private: + // preset two settings + // + // ******** + // ********** + // ******** + // + static constexpr float ROW_OFFSET_2 = 25; + static constexpr float COLUM_OFFSET_2 = 25; + static constexpr int COLUM_AMOUNT_2 = 10; + // preset three settings + // *** + // + // *** + // + // *** + static constexpr float ROW_OFFSET_3 = 100; + static constexpr float COLUM_OFFSET_3 = 25; + static constexpr int COLUM_AMOUNT_3 = 3; + // preset four settings + // *** + // + // *** + // + // *** + static constexpr float ROW_OFFSET_4 = 100; + static constexpr float COLUM_OFFSET_4 = 25; + static constexpr int COLUM_AMOUNT_4 = 3; + // preset five settings + // + // *** + // + static constexpr float ROW_OFFSET_5 = 25; + static constexpr float COLUM_OFFSET_5 = 25; + static constexpr int COLUM_AMOUNT_5 = 3; +}; |