-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNextLevel.h
More file actions
105 lines (83 loc) · 3.69 KB
/
NextLevel.h
File metadata and controls
105 lines (83 loc) · 3.69 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
#pragma once
#include "TextureManager.h"
class NextLevel {
private:
Font textFont;
Texture texture;
Text texts[4];
Sprite plantSprites[4];
Sprite zombieSprites[3];
Sprite backGroundSprite;
public:
NextLevel(TextureManager* TMptr) {
this->textFont.loadFromFile("assets/fonts/roman.otf");
this->texts[0] = Text("LEVEL CLEARED", this->textFont, 180); this->texts[0].setFillColor(Color::White);
this->texts[1] = Text("UNLOCKED: ", this->textFont, 85); this->texts[1].setFillColor(Color::Green);
this->texts[2] = Text("BEWARE OF: ", this->textFont, 85); this->texts[2].setFillColor(Color::Red);
this->plantSprites[0] = Sprite(TMptr->getTexture("spritesheet-wallnut"));
this->plantSprites[0].setTextureRect(IntRect(0, 0, 71, 71));
this->plantSprites[1] = Sprite(TMptr->getTexture("spritesheet-repeater"));
this->plantSprites[1].setTextureRect(IntRect(0, 0, 71, 71));
this->plantSprites[2] = Sprite(TMptr->getTexture("spritesheet-snowpea"));
this->plantSprites[2].setTextureRect(IntRect(0, 0, 71, 71));
this->plantSprites[3] = Sprite(TMptr->getTexture("spritesheet-cherrybomb"));
this->plantSprites[3].setTextureRect(IntRect(426, 0, 71, 71));
this->zombieSprites[0] = Sprite(TMptr->getTexture("football-walk"));
this->zombieSprites[0].setTextureRect(IntRect(0, 0, 166, 144));
this->zombieSprites[1] = Sprite(TMptr->getTexture("dancing-walk-1"));
this->zombieSprites[1].setTextureRect(IntRect(0, 0, 166, 144));
this->zombieSprites[2] = Sprite(TMptr->getTexture("flying-zombie"));
this->zombieSprites[2].setTextureRect(IntRect(0, 0, 88, 140));
this->backGroundSprite = Sprite(TMptr->getTexture("levelbg"));
this->backGroundSprite.setPosition(0, 0);
this->backGroundSprite.setColor(Color(255, 255, 255, 180));
this->texts[0].setPosition(190, 20);
this->texts[1].setPosition(385, 228);
this->plantSprites[0].setPosition(800, 235);
this->plantSprites[1].setPosition(900, 235);
this->plantSprites[2].setPosition(800, 235);
this->plantSprites[3].setPosition(900, 235);
this->texts[2].setPosition(375, 340);
this->zombieSprites[0].setPosition(770, 320);
this->zombieSprites[1].setPosition(780, 300);
this->zombieSprites[2].setPosition(850, 305);
}
void level2(RenderWindow& window) {
window.draw(this->backGroundSprite);
window.draw(this->texts[0]);
window.draw(this->texts[1]); window.draw(this->plantSprites[0]); window.draw(this->plantSprites[1]);
window.draw(this->texts[2]); window.draw(this->zombieSprites[0]);
window.draw(this->texts[3]);
}
void level3(RenderWindow& window) {
window.draw(this->backGroundSprite);
window.draw(this->texts[0]);
window.draw(this->texts[1]); window.draw(this->plantSprites[2]); window.draw(this->plantSprites[3]);
window.draw(this->texts[2]); window.draw(this->zombieSprites[1]);
window.draw(this->texts[3]);
}
void level4(RenderWindow& window) {
window.draw(this->backGroundSprite);
this->texts[2].setPosition(460, 280);
this->zombieSprites[2].setPosition(850, 245);
window.draw(this->texts[0]);
window.draw(this->texts[2]); window.draw(this->zombieSprites[2]);
}
void drawLevel(RenderWindow& window, int levelIndex) {
if (levelIndex == 1) level2(window);
else if (levelIndex == 2) level3(window);
else if (levelIndex == 3) level4(window);
}
void reset() {
this->texts[0].setPosition(650, 150);
this->texts[1].setPosition(500, 250);
this->plantSprites[0].setPosition(700, 250);
this->plantSprites[1].setPosition(900, 250);
this->plantSprites[2].setPosition(700, 250);
this->plantSprites[3].setPosition(900, 250);
this->texts[2].setPosition(500, 350);
this->zombieSprites[0].setPosition(700, 300);
this->zombieSprites[1].setPosition(700, 300);
this->zombieSprites[2].setPosition(700, 300);
}
};