-
Notifications
You must be signed in to change notification settings - Fork 0
/
general classes.h
384 lines (343 loc) · 17.4 KB
/
general classes.h
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
#pragma once
#include "body.h"
class Wall : public Body{ //êëàññ ñòåíû
public:
Wall (Texture *tmpTexture, String Name, int X, int Y, int W, int H, int WTexture, int HTexture) : Body (tmpTexture, Name, X, Y, W, H, WTexture, HTexture){ //êîíñòðóêòîð ñ èìåíåì
int GLOB_IND_W = (W_WIN - NUM_CELL_X * EDGE) / 2; //îòñòóï ïî øèðèíå, ñ êîòîðîãî íà÷èíàåòñÿ óðîâåíü
int GLOB_IND_H = (H_WIN - NUM_CELL_Y * EDGE) / 2; //îòñòóï ïî âûñîòå, ñ êîòîðîãî íà÷èíàåòñÿ óðîâåíü
shape.setPosition ((float) x * EDGE + GLOB_IND_W, (float) y * EDGE + GLOB_IND_H);
if (name == "Save") shape.setTextureRect (IntRect (0, 0, wTexture, hTexture)); //îïðåäåëÿåì òåêñòóðó äëÿ êàæäîãî âèäà ñòåíû
else if (name == "Wall") shape.setTextureRect (IntRect (0, hTexture, wTexture, hTexture));
else if (name == "Finish") shape.setTextureRect (IntRect (0, hTexture * 2, wTexture, hTexture));
else if (name == "Start") shape.setTextureRect (IntRect (0, hTexture * 3, wTexture, hTexture));
else if (name == "Circle") shape.setTextureRect (IntRect (0, hTexture * 4, wTexture, hTexture));
else if (name == "Rectangle") shape.setTextureRect (IntRect (0, hTexture * 5, wTexture, hTexture));
else if (name == "Triangle") shape.setTextureRect (IntRect (0, hTexture * 6, wTexture, hTexture));
}
Wall& operator= (const Wall& tmpW){ //â ôóíêöèè êëàññà Game åñòü ôóíêöèÿ createWall, òàì íóæåí îïåðàòîð ðàâíî
if (this != &tmpW){
x = tmpW.x; y = tmpW.y;
w = tmpW.w; h = tmpW.h;
name = tmpW.name;
wTexture = tmpW.wTexture; hTexture = tmpW.hTexture;
int GLOB_IND_W = (W_WIN - NUM_CELL_X * EDGE) / 2; //îòñòóï ïî øèðèíå, ñ êîòîðîãî íà÷èíàåòñÿ óðîâåíü
int GLOB_IND_H = (H_WIN - NUM_CELL_Y * EDGE) / 2; //îòñòóï ïî âûñîòå, ñ êîòîðîãî íà÷èíàåòñÿ óðîâåíü
shape.setPosition ((float) x * EDGE + GLOB_IND_W, (float) y * EDGE + GLOB_IND_H);
if (name == "Save") shape.setTextureRect (IntRect (0, 0, wTexture, hTexture));
else if (name == "Wall") shape.setTextureRect (IntRect (0, hTexture, wTexture, hTexture));
else if (name == "Finish") shape.setTextureRect (IntRect (0, hTexture * 2, wTexture, hTexture));
else if (name == "Start") shape.setTextureRect (IntRect (0, hTexture * 3, wTexture, hTexture));
else if (name == "Circle") shape.setTextureRect (IntRect (0, hTexture * 4, wTexture, hTexture));
else if (name == "Rectangle") shape.setTextureRect (IntRect (0, hTexture * 5, wTexture, hTexture));
else if (name == "Triangle") shape.setTextureRect (IntRect (0, hTexture * 6, wTexture, hTexture));
}
return *this;
}
void draw (){
window -> draw (shape);
}
void changeLocation (int tmpX, int tmpY){
shape.setPosition ((float) tmpX, (float) tmpY);
}
};
class Background : public Body{ //êëàññ ôîíîâîãî èçîáðàæåíèÿ
public:
Background (Texture *tmpTexture, String Name, int X, int Y, int W, int H, int WTexture, int HTexture) : Body (tmpTexture, Name, X, Y, W, H, WTexture, HTexture){
shape.setOrigin ((float) w / 2, (float) h / 2);
}
void changeLocation (int x2, int y2){ //ôóíêöèÿ èçìåíåíèÿ êîîðäèíàò
shape.setPosition ((float) x2, (float) y2);
}
void draw (){
window -> draw (shape);
}
};
class Player : public Body{ //êëàññ èãðîêà
private:
bool F_transformation; //ôëàã, êîòîðûé ïîêàçûâàåòñÿ òðàíñôîðìèðóåòñÿ ëè èãðîê
bool F_secPhaseTransformation; //ôëàã, êîòîðûé ïîêàçûâàåò âòîðàÿ ëè ôàçà òðàíñôîðìàöèè èãðîêà ñåé÷àñ
float reducePrecent; //ïðîöåíò óìåíüøåíèÿ
float enlargePrecent; //ïðîöåíò óâåëå÷åíèÿ
float rotation; //óãîë íà êîòîðûé ïîâîðà÷èâàåòñÿ èãðîê ïðè ýôôåêòå êîíöà óðîâíÿ è íà÷àëå èãðû
int dir; //íàïðàâëåíèå, â êîòîðîì äâèæåòñÿ èãðîê â äàííûé ìîìåíò
StatePlayer stateWill; //õðàíèò ñîñòîÿíèå â êîòîðîå òðàíñôîðìèðóåòñÿ èãðîê
public:
bool F_move; //ôëàã, êîòîðûé ïîêàçûâàåò äâèæåòñÿ ëè èãðîê
bool F_teleportation; //ôëàã, êîòîðûé ïîêàçûâàåò èãðîê òåëåïîðòèðóåòñÿ ëè
bool F_reduce; //ôëàã, êîòîðûé ïîêàçûâàåò óìåíüøàåòñÿ ëè èãðîê â äàííûé ìîìåíò
bool F_enlarge; //ôëàã, êîòîðûé ïîêàçûâàåò èäåò ëè ýôôåêò íà÷àëà èãðû
int currDirection; //òåêóùåå íàïðàâëåíèå
StatePlayer state; //ñîñòîÿíèå èãðîêà ñîîòâåñòâóåò ôèãóðå
private:
void EFF_reduce (){ //óìåíüøåíèå èãðîêà (êîíåö óðîâíÿ)
shape.setSize (Vector2f ((float) w * reducePrecent / 100, (float) h * reducePrecent / 100));
shape.setOrigin ((float) w * reducePrecent / 100 / 2, (float) h * reducePrecent / 100 / 2);
shape.setPosition ((float) W_WIN / 2, (float) H_WIN / 2);
shape.setRotation (rotation);
rotation += speedChangeSt * time * 1.5f;
reducePrecent -= speedChangeSt * time / 3;
if (reducePrecent < speedChangeSt * time / 3){ //êîãäà ïðåêðàòèòñÿ èçìåíåíèå ôîðìû
reducePrecent = 100; F_lvlComplete = true; //òîãäà è óðîâåíü çàêîí÷èòñÿ
rotation = 0; F_reduce = false;
}
}
void EFF_transformation (){ //ýôôåêò èçìåíåíèÿ ôèãóðû èãðîêà
if (F_secPhaseTransformation){ //óâåëå÷åíèå èãðîêà
shape.setSize (Vector2f ((float) w * timer / 0.15f, (float) h * timer / 0.15f));
shape.setOrigin ((float) w * timer / 0.15f / 2, (float) h * timer / 0.15f / 2);
shape.setPosition ((float) W_WIN / 2, (float) H_WIN / 2);
}
else{ //óìåíüøåíèå èãðîêà
shape.setSize (Vector2f ((float) w * (1 - timer / 0.15f), (float) h * (1 - timer / 0.15f)));
shape.setOrigin ((float) w * (1 - timer / 0.15f) / 2, (float) h * (1 - timer / 0.15f) / 2);
shape.setPosition ((float) W_WIN / 2, (float) H_WIN / 2);
}
if (timer >= 0.15f && !F_secPhaseTransformation){
F_secPhaseTransformation = true;
timer = 0;
state = stateWill;
changeFigureStatic ();
}
else if (timer >= 0.15f && F_secPhaseTransformation){
timer = 0;
F_secPhaseTransformation = false;
F_transformation = false; //îí ìîæåò âêîíöå èìåòü íå ïîëíûé ðàçìåð, ïîýòîìó ïðèâîäèì åãî ê 100% ðàçìåðó
shape.setSize (Vector2f ((float) w, (float) h));
shape.setOrigin ((float) w / 2, (float) h / 2);
shape.setPosition ((float) W_WIN / 2, (float) H_WIN / 2);
}
}
public:
Player (Texture *tmpTexture, int X, int Y, int W, int H, int WTexture, int HTexture) : Body (tmpTexture, "Player", X, Y, W, H, WTexture, HTexture){ //êîíñòðóêòîð áåç èìåíè
F_move = false; F_reduce = false;
F_teleportation = false; F_transformation = false; F_secPhaseTransformation = false;
reducePrecent = 100; rotation = 0; enlargePrecent = 1; F_enlarge = false;
currDirection = 0; state = rectangle;
shape.setTextureRect (IntRect (0, hTexture, wTexture, hTexture));
shape.setPosition ((float) W_WIN / 2, (float) H_WIN / 2);
shape.setOrigin ((float) w / 2, (float) h / 2);
}
void EFF_enlarge (){ //óâåëå÷åíèå èãðîêà (âíà÷àëå èãðû)
if (F_enlarge){
shape.setSize (Vector2f ((float) w * enlargePrecent / 100, (float) h * enlargePrecent / 100));
shape.setOrigin ((float) w * enlargePrecent / 100 / 2, (float) h * enlargePrecent / 100 / 2);
shape.setPosition ((float) W_WIN / 2, (float) H_WIN / 2);
shape.setRotation (rotation);
rotation += (float) (speedChangeSt * time * 1.5);
enlargePrecent += speedChangeSt * time / 3;
if (enlargePrecent > 100 - speedChangeSt * time / 3){ //êîãäà ïðåêðàòèòñÿ èçìåíåíèå ôîðìû
enlargePrecent = 1; F_enlarge = false;
shape.setSize (Vector2f ((float) w, (float) h));
shape.setOrigin ((float) w / 2, (float) h / 2);
shape.setPosition ((float) W_WIN / 2, (float) H_WIN / 2);
shape.setRotation (0); rotation = 0;
}
}
}
void changeFigureKey (){ //èçìåíåíèå ôèãóðû ïî íàæàòèþ êëàâèøè
if (!F_secPhaseTransformation){ //ïîêà èäåò óìåíüøåíèå èãðîêà, ìîæíî ïîìåíÿòü ôèãóðó â êîòîðóþ èãðîê áóäåò óâåëè÷èâàòüñÿ
if (keyCodePressed == key [0]){
if (state != rectangle){
F_transformation = true; stateWill = rectangle;
}
}
else if (keyCodePressed == key [1]){
if (state != triangle){
F_transformation = true; stateWill = triangle;
}
}
else if (keyCodePressed == key [2]){
if (state != circle){
F_transformation = true; stateWill = circle;
}
}
}
if (F_transformation){ //åñëè òðàíñôîðìèðóåòñÿ
EFF_transformation (); timer += time;
}
}
void changeFigureStatic (){ //èçìåíåíèå ôèãóðû ñîîòâåñòâóþùåìó ñîñòîÿíèþ èãðîêà
if (state == rectangle) shape.setTextureRect (IntRect (0, hTexture, wTexture, hTexture));
else if (state == triangle) shape.setTextureRect (IntRect (0, hTexture * 2, wTexture, hTexture));
else if (state == circle) shape.setTextureRect (IntRect (0, 0, wTexture, hTexture));
}
void update (){
if (!F_teleportation){
if (currDirection < NumMoves && !F_move){ //â ìàññèâå õðàíÿòñÿ íàïðàâëåíèÿ, â êîòîðå äîëæåí äâèãàòüñÿ èãðîê, ÷òî á äîñòè÷ü ôèíèøà
if (Direction [currDirection] == 4) { y--; dir = 4; } //õ è ó õðàíÿò êîîðäèíàòû íà óðîâíå! ò.å. õ îò 0 äî 31, ó îò 0 äî 63
else if (Direction [currDirection] == 1) { y++; dir = 1; }
else if (Direction [currDirection] == 2) { x--; dir = 2; }
else if (Direction [currDirection] == 3) { x++; dir = 3; }
currDirection++; F_move = true;
}
changeFigureKey ();
if (F_move){ //íà÷àëî êîîðäèíàò â ëåâîì âåðõíåì óãëó â SFML, à ïðî äâèæåíèå èãðîêà íàïèñàíî äëÿ ãëàç èãðîêà
if (dir == 3){ //äâèæåíèå êàðòû âëåâî, à áóäåò âûãëÿäåòü êàê èãðîê äâèæåòñÿ âïðàâî
map.move (-speed * time, 0);
if (map.getPosition ().x - (W_WIN / 2 - SQUARE) < 3 * SQUARE * time || map.getPosition ().x < W_WIN / 2 - SQUARE){
map.setOrigin ((float) SQUARE * x + 3 * SQUARE / 2, (float) SQUARE * y + 3 * SQUARE / 2);
map.setPosition ((float) W_WIN / 2, (float) H_WIN / 2);
F_move = false;
}
}
else if (dir == 2){ //äâèæåíèå êàðòû âïðàâî, à áóäåò âûãëÿäåòü êàê èãðîê äâèæåòñÿ íà ëåâî
map.move (speed * time, 0);
if ((W_WIN / 2 + SQUARE - map.getPosition ().x < 3 * SQUARE * time) || map.getPosition ().x > W_WIN / 2 + SQUARE){
map.setOrigin ((float) SQUARE * x + 3 * SQUARE / 2, (float) SQUARE * y + 3 * SQUARE / 2);
map.setPosition ((float) W_WIN / 2, (float) H_WIN / 2);
F_move = false;
}
}
else if (dir == 1){ //äâèæåíèå èãðîêà âíèç
map.move (0, -speed * time);
if ((map.getPosition ().y - (H_WIN / 2 - SQUARE) < 3 * SQUARE * time) || map.getPosition ().y < H_WIN / 2 - SQUARE){
map.setOrigin ((float) SQUARE * x + 3 * SQUARE / 2, (float) SQUARE * y + 3 * SQUARE / 2);
map.setPosition ((float) W_WIN / 2, (float) H_WIN / 2);
F_move = false;
}
}
else if (dir == 4){ //äâèæåíèå èãðîê ââåðõ
map.move (0, speed * time);
if ((H_WIN / 2 + SQUARE - map.getPosition ().y < 3 * SQUARE * time) || map.getPosition ().y > H_WIN / 2 + SQUARE){
map.setOrigin ((float) SQUARE * x + 3 * SQUARE / 2, (float) SQUARE * y + 3 * SQUARE / 2);
map.setPosition ((float) W_WIN / 2, (float) H_WIN / 2);
F_move = false;
}
}
}
}
if (x == Finish.x && y == Finish.y && !F_move){ //åñäè ìû äîñòèãëè ôèíèøà
EFF_reduce (); F_transformation = false; //íà÷èíàåì óìåíüøåíèå
F_secPhaseTransformation = false; F_reduce = true;
}
}
void changeLocation (int x2, int y2){ //ôóíêöèÿ íóæíà äëÿ ïåðåìåùåíèÿ èãðîêà â íóæíóþ êîîðäèíàòó (íóæíî ïðè îòêðûòèè óðîâíÿ èãðîêîì)
shape.setSize (Vector2f ((float) w, (float) h));
shape.setOrigin ((float) w / 2, (float) h / 2);
shape.setPosition ((float) W_WIN / 2, (float) H_WIN / 2);
shape.setRotation (0);
enlargePrecent = 1; reducePrecent = 100;
rotation = 360 - ((FPS * (100 / speedChangeSt) * 3) * (float) (speedChangeSt * time * 1.5)); //âûñ÷èòûâàåì óãîë íà êîòîðûé íàäî ïîâåðíóòü èãðîêà, ÷òî á îí ïîòîì ñòàë â íîðìàëüíîå ïîëîæåíèå
x = x2; y = y2;
map.setOrigin ((float) SQUARE * x + 3 * SQUARE / 2, (float) SQUARE * y + 3 * SQUARE / 2);
map.setPosition ((float) W_WIN / 2, (float) H_WIN / 2);
}
void EFF_teleportation (int x2, int y2){ //ýôôåêò òåëåïîðòàöèè èãðîêà
shape.setTextureRect (IntRect (0, hTexture * 3, wTexture, hTexture));
shape.setSize (Vector2f ((float) w * (1 - timer / 0.3f), (float) h * (1 - timer / 0.3f)));
shape.setOrigin ((float) w * (1 - timer / 0.3f) / 2, (float) h * (1 - timer / 0.3f) / 2);
shape.setPosition ((float) W_WIN / 2, (float) H_WIN / 2);
F_teleportation = true;
if (timer > 0.3){
timer = 0;
x = x2; y = y2;
F_teleportation = false; F_transformation = false; F_secPhaseTransformation = false;
shape.setSize (Vector2f ((float) w, (float) h)); //äîâîäèì åãî ðàçìåð äî 100%
shape.setOrigin ((float) w / 2, (float) h / 2);
shape.setPosition ((float) W_WIN / 2, (float) H_WIN / 2);
changeFigureStatic ();
}
}
void draw (){
window -> draw (shape);
}
};
class BodyButton : public Body{ //òåëî êíîïîê
protected:
int sizeText; //ðàçìåð òåêñòà íà êíîïêå
bool F_pressed; //ôëàã, êîòîðûé ïîêàçûâàåò íàæàòà ëè êíîïêà
float reducePrecent; //ïðîöåíò óìåíüøåíèÿ
float enlargePrecent; //ïðîöåíò óâåëå÷åíèÿ
Color color; //öâåò òåêñòà êíîïêè
mcText *text; //òåêñò êîòîðûé âûâîäèòñÿ íà êíîïêå (îáúåêò êëàññà, â êîòîðîì åñòü óäîáíûå ìåòîäû äëÿ âûâîäà òåêñòà â îêíî)
String buttText; //òåêñò êîòîðûé áóäåò îòîáðàæàòüñÿ íà êíîïêå
private:
Font font; //øðèôò
public:
bool F_draw; //ôëàã, êîòîðûé ïîêàçûâàåò ðèñóåòñÿ ëè ýòà êíîïêà
bool F_click; //ôëàã, êîòîðûé ïîêàçûâàåò êëèêíóëè ëè ïî êíîïêå (êëèê- ýòî íàæàòü è îòïóñòèòü êíîïêó êîãäà êóðñîð ìûøè íà êíîïêå)
bool F_transformation; //ôëàã, êîòîðûé ïîêàçûâàåò èçìåíèëàñü ëè ôîðìà
int value; //çíà÷åíèå êíîïêè (íóæíî äëÿ êíîïîê ñ öèôðàìè äëÿ âûáîðà óðîâíÿ)
TypeState type; //òèï ñîñòîÿíèÿ ê êîòîðîìó ïðèíàäëåæèò êíîïêà
SubtypeState subtype; //ïîäòèï ñîñòîÿíèÿ ê êîòîðîìó ïðèíàäëåæèò êíîïêà
public:
BodyButton (Texture *tmpTexture, String Text, String Name, Font &Font, SubtypeState &Subtype, int X, int Y, int W, int H, int WTexture, int HTexture) :
Body (tmpTexture, Name, X, Y, W, H, WTexture, HTexture){
font = Font; buttText = Text; sizeText = SIZE_TEXT;
subtype = Subtype; type = findType (subtype); //íàøëè òèï ê êîòîðîìó îòíîñèòñÿ êíîïêà
F_draw = false; F_click = false; F_pressed = false;
F_transformation = false; reducePrecent = 100; enlargePrecent = 1;
color = Color::Black; //ïî óìîë÷àíèþ òåêñò ÷åðíûé
text = new mcText (&font); //ñîçäàåì òåêñò êîòîðûé áóäåò îòîáðàæàòüñÿ íà êíîïêå
text -> changeSize (sizeText); //ðàçìåð òåêñòà
text -> add (buttText, color);
text -> setPosition ((float) x - text -> w / 2, (float) y - 2 * sizeText / 3); //ðàñïîëîãàåì òåêñò ïî êíîïêå
shape.setOrigin ((float) w / 2, (float) h / 2);
}
BodyButton (Texture *tmpTexture, String Name, SubtypeState &Subtype, int X, int Y, int W, int H, int WTexture, int HTexture) : //äëÿ ïèê÷åð áàòòîí, ÷åê áàòòîí è ãîðèçîíòàë ñêðîë áàð
Body (tmpTexture, Name, X, Y, W, H, WTexture, HTexture){
subtype = Subtype; type = findType (subtype);
F_draw = false; F_click = false; F_pressed = false;
F_transformation = false; reducePrecent = 100; enlargePrecent = 1;
sizeText = SIZE_TEXT;
shape.setOrigin ((float) w / 2, (float) h / 2);
}
BodyButton (String Text, String Name, Font &Font, SubtypeState &Subtype, int X, int Y) : //äëÿ ñòàòèêà ñäåëàíà ïåðåãðóçêà
Body (Name, X, Y, 1, 1, 1, 1){
font = Font; buttText = Text; sizeText = SIZE_TEXT;
subtype = Subtype; type = findType (subtype);
F_draw = false; F_click = false; F_pressed = false;
F_transformation = false; reducePrecent = 100; enlargePrecent = 1;
color = Color::Black;
text = new mcText (&font); //ñîçäàåì òåêñò êîòîðûé áóäåò îòîáðàæàòüñÿ íà êíîïêå
text -> changeSize (sizeText); //ðàçìåð òåêñòà
text -> add (buttText, color);
text -> setPosition ((float) x - text -> w / 2, (float) y - 2 * sizeText / 3); //ðàñïîëîãàåì òåêñò ïî êíîïêå
}
void draw (){ }
virtual void checkCursor () = 0;
virtual void updateText (char *Pass) = 0;
virtual void EFF_reduce (){ //óìåíüøåíèå êíîïêè
if (F_transformation){
shape.setSize (Vector2f ((float) w * reducePrecent / 100, (float) h * reducePrecent / 100));
shape.setOrigin ((float) w * reducePrecent / 100 / 2, (float) h * reducePrecent / 100 / 2);
shape.setPosition ((float) x, (float) y);
text -> clear ();
text -> changeSize (sizeText * (int) reducePrecent / 100); //ðàçìåð òåêñòà
text -> add (buttText, color);
text -> setPosition ((float) x - text -> w / 2, (float) y - 2 * sizeText * reducePrecent / 100 / 3); //ðàñïîëîãàåì òåêñò ïî êíîïêå
reducePrecent -= speedChangeSt * time;
if (reducePrecent < speedChangeSt * time){ //êîãäà ïðåêðàòèòñÿ èçìåíåíèå ôîðìû
reducePrecent = 100;
F_transformation = false;
}
}
}
virtual void EFF_enlarge (){ //óâåëå÷åíèå êíîïêè
if (F_transformation){
shape.setSize (Vector2f ((float) w * enlargePrecent / 100, (float) h * enlargePrecent / 100));
shape.setOrigin ((float) w * enlargePrecent / 100 / 2, (float) h * enlargePrecent / 100 / 2);
shape.setPosition ((float) x, (float) y);
text -> clear ();
text -> changeSize (sizeText * (int) enlargePrecent / 100); //ðàçìåð òåêñòà
text -> add (buttText, color);
text -> setPosition ((float) x - text -> w / 2, (float) y - 2 * sizeText * enlargePrecent / 100 / 3); //ðàñïîëîãàåì òåêñò ïî êíîïêå
enlargePrecent += speedChangeSt * time;
if (enlargePrecent > 100 - speedChangeSt * time){ //êîãäà ïðåêðàòèòñÿ èçìåíåíèå ôîðìû
enlargePrecent = 1;
F_transformation = false;
shape.setSize (Vector2f ((float) w, (float) h)); //ïðèâîäèì ê 100% ðàçìåðó
shape.setOrigin ((float) w / 2, (float) h / 2);
shape.setPosition ((float) x, (float) y);
text -> clear ();
text -> changeSize (sizeText); //ðàçìåð òåêñòà
text -> add (buttText, color);
text -> setPosition ((float) x - text -> w / 2, (float) y - 2 * sizeText / 3); //ðàñïîëîãàåì òåêñò ïî êíîïêå
}
}
}
virtual void clear (){ //ôóíêöèÿ î÷èùåíèÿ êíîïêè, íóæíà ÷òî á íà÷àòü êíîïêè óâåëè÷èâàòü (âòîðàÿ ôàçà)
shape.setSize (Vector2f (1, 1));
text -> clear ();
}
};