aboutsummaryrefslogtreecommitdiff
path: root/game/coins/CoinSystemScript.h
blob: f558f0813601b08b71da70b754155665b8f139d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#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>

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 = 1200;
	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;
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;
};