aboutsummaryrefslogtreecommitdiff
path: root/game/coins/CoinSystemScript.h
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2025-01-08 15:03:14 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2025-01-08 15:03:14 +0100
commit261a2cfd2bedafbc7fcf54e1b86adee206dea519 (patch)
treef099bca292e99ae54035f9a5ac7a455eec073c3e /game/coins/CoinSystemScript.h
parentd9c67da9b8c2d8d25ef4dd2c700ddc78573d3a60 (diff)
parent0b9574bdd6c5968c07bcf165d66032b75649b5da (diff)
merge w/ master
Diffstat (limited to 'game/coins/CoinSystemScript.h')
-rw-r--r--game/coins/CoinSystemScript.h105
1 files changed, 57 insertions, 48 deletions
diff --git a/game/coins/CoinSystemScript.h b/game/coins/CoinSystemScript.h
index f558f08..5c94273 100644
--- a/game/coins/CoinSystemScript.h
+++ b/game/coins/CoinSystemScript.h
@@ -1,27 +1,33 @@
#pragma once
-#include "types.h"
-#include <string>
-#include "api/CircleCollider.h"
-#include "api/Script.h"
-#include "api/Sprite.h"
-#include "api/Transform.h"
#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};
+ 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) {}
+ 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 add_location(const crepe::vec2 & location);
void despawn_coins();
void spawn_coins();
void generate_locations();
@@ -30,68 +36,71 @@ private:
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::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 = 1200;
+ 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;
- static std::vector<CoinData> coin_locations;
+ std::vector<CoinData> coin_locations;
+
private:
-// preset one settings
-// ***** *****
-//
-//
-//
-// ***** *****
+ // 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
-//
-// ********
-// **********
-// ********
-//
+ // 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
-// ***
-//
-// ***
-//
-// ***
+ // 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
-// ***
-//
-// ***
-//
-// ***
+ // 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
-//
-// ***
-//
+ // preset five settings
+ //
+ // ***
+ //
static constexpr float ROW_OFFSET_5 = 25;
static constexpr float COLUM_OFFSET_5 = 25;
static constexpr int COLUM_AMOUNT_5 = 3;