-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLevelMaker.cpp
More file actions
125 lines (109 loc) · 4.37 KB
/
LevelMaker.cpp
File metadata and controls
125 lines (109 loc) · 4.37 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//
// Created by viviane on 24/11/2021.
//
#include "LevelMaker.h"
namespace levels{
LevelMaker::LevelMaker() {}
LevelMaker::LevelMaker(Player* p, EntityList* list, AssetManager* asset) :
player(p),
entityList(list),
assets(asset){
srand(time(NULL));
Xposition = 0;
max_entities = 0;
}
LevelMaker::~LevelMaker(){
}
void LevelMaker::createWeakGoblin(){
max_entities = rand() % RAND_ENTITIES;
for (int i = 0; i < (3 + max_entities); i++){
Xposition = (rand() % POSITION_MAX) + POSITION_MIN;
WeakGoblin* weakGoblin = new WeakGoblin();
weakGoblin->setPlayer(player);
weakGoblin->setSprite(assets->getSprite("weakGoblin"));
weakGoblin->setPosition(Xposition);
if (entityList && assets){
entityList->push(static_cast<entities::Entity*>(weakGoblin));
assets->getSprite("darkEnergyOrb")->setScale(0.1, 0.1);
assets->getSprite("weakGoblin")->setScale(0.7, 0.7);
}
}
}
void LevelMaker::createStrongGoblin(){
max_entities = rand() % RAND_ENTITIES;
for (int i = 0; i < (3 + max_entities); i++){
Xposition = (rand() % POSITION_MAX) + POSITION_MIN;
StrongGoblin* strongGoblin = new StrongGoblin();
strongGoblin->setPlayer(player);
strongGoblin->setPosition(Xposition);
strongGoblin->setSprite(assets->getSprite("strongGoblin"));
if (entityList && assets){
entityList->push(static_cast<entities::Entity*>(strongGoblin));
assets->getSprite("strongGoblin")->setScale(0.7, 0.7);
}
}
}
void LevelMaker::createBossGoblin(){
BossGoblin* bossGoblin = new BossGoblin();
bossGoblin->setPlayer(player);
bossGoblin->setPosition(BOSS_POSITION);
bossGoblin->setSprite(assets->getSprite("bossGoblin"));
if (entityList && assets){
entityList->push(static_cast<entities::Entity*>(bossGoblin));
assets->getSprite("energyOrb")->setScale(0.1, 0.1);
assets->getSprite("bossGoblin")->setScale(2, 2);
}
}
void LevelMaker::createSpikes(){
max_entities = rand() % RAND_ENTITIES;
for (int i = 0; i < (3 + max_entities); i++){
Xposition = (rand() % POSITION_MAX) + POSITION_MIN;
Spikes* spikes = new Spikes();
spikes->setPosition(Xposition);
spikes->setSprite(assets->getSprite("spikes"));
if (entityList && assets){
entityList->push(static_cast<entities::Entity*>(spikes));
assets->getSprite("spikes")->setScale(0.7, 0.7);
}
}
}
void LevelMaker::createFirePit(){
max_entities = rand() % RAND_ENTITIES;
for (int i = 0; i < (3 + max_entities); i++){
Xposition = (rand() % POSITION_MAX) + POSITION_MIN;
//Ver se teve colisão com alguma coisa
FirePit* firePit = new FirePit();
firePit->setPosition(Xposition);
firePit->setSprite(assets->getSprite("firePit"));
if (entityList && assets){
entityList->push(static_cast<entities::Entity*>(firePit));
assets->getSprite("firePit")->setScale(1.5, 1.5);
}
}
}
void LevelMaker::createPointyBush(){
max_entities = rand() % RAND_ENTITIES;
for (int i = 0; i < (3 + max_entities); i++){
Xposition = (rand() % POSITION_MAX) + POSITION_MIN;
PointyBush* pointyBush = new PointyBush();
pointyBush->setPosition(Xposition);
pointyBush->setSprite(assets->getSprite("pointyBush"));
if (entityList && assets){
entityList->push(static_cast<entities::Entity*>(pointyBush));
assets->getSprite("pointyBush")->setScale(0.7, 0.7);
}
}
}
void LevelMaker::renderObstacles(){
createFirePit();
createPointyBush();
createSpikes();
}
void LevelMaker::renderFinishLine() {
entities::FinishLine* finish = new entities::FinishLine();
if (entityList && assets) {
entityList->push(static_cast<entities::Entity *>(finish));
assets->getSprite("pointyBush")->setScale(0.7, 0.7);
}
}
}