-
Notifications
You must be signed in to change notification settings - Fork 1
/
ObstacleSprite.cpp
220 lines (146 loc) · 5.14 KB
/
ObstacleSprite.cpp
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#include "Sprites.h"
#include "Game.h"
void DyingTree1::init() {
getCollider().resize(1);
getCollider().setCollisionTag("Sh*t! caught in the Dying Trees!\nWriggle out for your next run?");
setSrcRect(0, 0, 32, 32);
setTransform(Game::mSCREEN_WIDTH + 101, 263, 136, 137);
}
void DyingTree1::update() {
TransformComponent& rTransform = getTransform();
if (rTransform.mVelocity.x < 0) {
getCollider().setColliderRect(0, rTransform.mPosition.x + 49, rTransform.mPosition.y + 4, 100, 136);
}
}
void DyingTree2::init() {
getCollider().resize(1);
getCollider().setCollisionTag("Sh*t! caught in the Dying Trees!\nWriggle out for your next run?");
setSrcRect(32, 0, 32, 32);
setTransform(Game::mSCREEN_WIDTH + 101, 263, 136, 137);
}
void DyingTree2::update() {
TransformComponent& rTransform = getTransform();
if (rTransform.mVelocity.x < 0) {
getCollider().setColliderRect(0, rTransform.mPosition.x + 36, rTransform.mPosition.y + 46, 40, 87);
}
}
void Bucket::init() {
getCollider().resize(1);
getCollider().setCollisionTag("Danmit! You've kicked The Bucket\nDid I mention you have nine (ahem) lives?");
setSrcRect(64, 0, 32, 32);
setTransform(Game::mSCREEN_WIDTH + 101, Game::mSCREEN_HEIGHT - 240, 153, 160);
}
void Bucket::update() {
TransformComponent& rTransform = getTransform();
if (rTransform.mVelocity.x < 0) {
getCollider().setColliderRect(0, rTransform.mPosition.x + 25, rTransform.mPosition.y + 29, 128, 100);
}
}
void TreeStump::init() {
getCollider().resize(1);
getCollider().setCollisionTag("Oof! crashed right into a Tree Stump!\nWatch your path, Rex!");
setSrcRect(0, 32, 32, 32);
setTransform(Game::mSCREEN_WIDTH + 101, 263, 136, 137);
}
void TreeStump::update() {
TransformComponent& rTransform = getTransform();
if (rTransform.mVelocity.x < 0) {
getCollider().setColliderRect(0, rTransform.mPosition.x + 61, rTransform.mPosition.y + 81, 81, 51);
}
}
void Stalker::init() {
getCollider().resize(1);
getCollider().setCollisionTag("Hehe, the one-eyed Stalker...\nLook away next time, okay?");
if (Game::mSpeedToggled) {
setAnimation(1, 2, 150);
}
else {
setAnimation(1, 2, 200);
}
setSrcRect(32, 32, 32, 32);
setTransform(Game::mSCREEN_WIDTH + 101, 263, 136, 137);
}
void Stalker::update() {
TransformComponent& rTransform = getTransform();
SDL_Rect& rSrcRect = getSrcRect();
if (rTransform.mVelocity.x < 0) {
getCollider().setColliderRect(0, rTransform.mPosition.x + 54, rTransform.mPosition.y + 4, 82, 136);
}
rSrcRect.x = 32 + (rSrcRect.w * static_cast<int>((SDL_GetTicks() / getFramesSpeed()) % getFramesCount()));
rSrcRect.y = getSheetIndex() * rSrcRect.h;
}
void Brute::init() {
getCollider().resize(1);
getCollider().setCollisionTag("Ouch, crushed by the merciless Brute!\nOh well, you're not THAT hurt, go again?");
if (Game::mSpeedToggled) {
setAnimation(2, 2, 150);
}
else {
setAnimation(2, 2, 200);
}
setSrcRect(0, 64, 32, 32);
setTransform(Game::mSCREEN_WIDTH + 101, 247, 153, 153);
}
void Brute::update() {
TransformComponent& rTransform = getTransform();
SDL_Rect& rSrcRect = getSrcRect();
if (rTransform.mVelocity.x < 0) {
getCollider().setColliderRect(0, rTransform.mPosition.x + 25, rTransform.mPosition.y + 28, 125, 130);
}
rSrcRect.x = rSrcRect.w * static_cast<int>((SDL_GetTicks() / getFramesSpeed()) % getFramesCount());
rSrcRect.y = getSheetIndex() * rSrcRect.h;
}
void StalkerPup::init() {
auto upMidDown = std::rand() % 15;
if (Game::mSpeedToggled) {
setAnimation(3, 2, 150);
}
else {
setAnimation(3, 2, 200);
}
setSrcRect(0, 96, 32, 32);
getCollider().resize(1);
getCollider().setCollisionTag("Yikes, Stalker Pups...\nNothing to see or say here, Rex, run again?");
if (upMidDown <= 7) {
setTransform(Game::mSCREEN_WIDTH + 101, 220, 103, 105);
}
else if (upMidDown <= 15) {
setTransform(Game::mSCREEN_WIDTH + 101, Game::mSCREEN_HEIGHT - 200, 103, 105);
}
}
void StalkerPup::update() {
TransformComponent& rTransform = getTransform();
SDL_Rect& rSrcRect = getSrcRect();
if (rTransform.mVelocity.x < 0) {
getCollider().setColliderRect(0, rTransform.mPosition.x + 12, rTransform.mPosition.y, 100, 75);
}
rSrcRect.x = rSrcRect.w * static_cast<int>((SDL_GetTicks() / getFramesSpeed()) % getFramesCount());
rSrcRect.y = getSheetIndex() * rSrcRect.h;
}
void Gale::init() {
auto upMidDown = std::rand() % 15;
if (Game::mSpeedToggled) {
setAnimation(4, 2, 150);
}
else {
setAnimation(4, 2, 200);
}
setSrcRect(0, 128, 32, 32);
getCollider().resize(1);
getCollider().setCollisionTag("Whoaa, you let the Night Gale sweep you away?\nHold on tight next run!");
if (upMidDown <= 7) {
setTransform(Game::mSCREEN_WIDTH + 101, 220, 103, 105);
}
else if (upMidDown <= 15) {
setTransform(Game::mSCREEN_WIDTH + 101, Game::mSCREEN_HEIGHT - 200, 103, 105);
}
}
void Gale::update() {
TransformComponent& rTransform = getTransform();
SDL_Rect& rSrcRect = getSrcRect();
if (rTransform.mVelocity.x < 0) {
getCollider().setColliderRect(0, rTransform.mPosition.x + 12, rTransform.mPosition.y, 100, 75);
}
rSrcRect.x = rSrcRect.w * static_cast<int>((SDL_GetTicks() / getFramesSpeed()) % getFramesCount());
rSrcRect.y = getSheetIndex() * rSrcRect.h;
}