-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSource.cpp
More file actions
1955 lines (1540 loc) · 49.8 KB
/
Source.cpp
File metadata and controls
1955 lines (1540 loc) · 49.8 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
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
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <SFML\Graphics.hpp>
#include<iostream>
#include<SFML\Audio.hpp>
#include <fstream>
#include <sstream>
#include <windows.h>
#define Max_main_menu 7
using namespace std;
using namespace sf;
int page_number;
sf::Vector2f pos(320, 750);//posetion to player
sf::Vector2f vel(0, 0); // player velocity (per frame)
sf::Vector2f gravity(0, 0.5f); // gravity (per frame)
Vector2i bodysize(65, 55);
Vector2f Posetion(190, 500);
const float maxfall = 3; // max fall velocity
const float runacc = .25f; // run acceleratio
const float maxrun = 2.5f; // max run velocity
const float jumpacc = -2.5; // jump acceleration
const unsigned int jumpframes = 10; // number of frames to accelerate in
unsigned int jumpcounter = 0; // counts the number of frames where you can still accelerate
int sel_player = 0;
int scoree = 0;
int score = 0;
bool hid_menu = false;
bool hid = true;
bool hid_play = true;
bool end1 = true;
bool level2 = true;
bool level3 = true;
bool level4 = true;
int bonus = 0;
Clock last;
int compo;
Vector2f sd(1080, 800); //for window
string num_step;
String score_string;
int highscoree;
struct location //structu for steps
{
int x, y, w, h;
}floorlocation[1000];
class Main_menu //menuu
{
public:
Main_menu(float width, float hight);
void draw(sf::RenderWindow& window);
void moveUp();
void moveDown();
int mainMenuPressed()
{
return mainMenuSelected;
}
~Main_menu();
private:
int mainMenuSelected;
sf::Font font;
sf::Text mainMenu[Max_main_menu];
};
Main_menu::Main_menu(float width, float height)
{
if (!font.loadFromFile("font/DSSnowfall.ttf")) {}
//play
mainMenu[0].setFont(font);
mainMenu[0].setFillColor(sf::Color::Blue);
mainMenu[0].setString("PLAY GAME");
mainMenu[0].setCharacterSize(35);
mainMenu[0].setPosition(sf::Vector2f(600, 470));
mainMenu[0].setScale(.9, 1);
//INSTRUCTIONS
mainMenu[1].setFont(font);
mainMenu[1].setFillColor(sf::Color::White);
mainMenu[1].setString("INSTRUCTIONS");
mainMenu[1].setCharacterSize(35);
mainMenu[1].setPosition(sf::Vector2f(600, 510));
mainMenu[1].setScale(.9, 1);
mainMenu[1].setOutlineThickness(.1);
mainMenu[1].setOutlineColor(Color::White);
//PROFILE
mainMenu[2].setFont(font);
mainMenu[2].setFillColor(sf::Color::White);
mainMenu[2].setString("CREDITS");
mainMenu[2].setCharacterSize(35);
mainMenu[2].setPosition(sf::Vector2f(600, 550));
mainMenu[2].setScale(.9, 1);
mainMenu[2].setOutlineThickness(.1);
mainMenu[2].setOutlineColor(Color::White);
//HIGH SCORES
mainMenu[3].setFont(font);
mainMenu[3].setFillColor(sf::Color::White);
mainMenu[3].setString("ABOUT THE GAME");
mainMenu[3].setCharacterSize(30);
mainMenu[3].setPosition(sf::Vector2f(600, 590));
mainMenu[3].setScale(.9, 1);
mainMenu[3].setOutlineThickness(.1);
mainMenu[3].setOutlineColor(Color::White);
//options sound
mainMenu[4].setFont(font);
mainMenu[4].setFillColor(sf::Color::White);
mainMenu[4].setString("OPTIONS SOUND");
mainMenu[4].setCharacterSize(35);
mainMenu[4].setPosition(sf::Vector2f(600, 630));
mainMenu[4].setScale(.9, 1);
mainMenu[4].setOutlineThickness(.1);
mainMenu[4].setOutlineColor(Color::White);
//exit
mainMenu[5].setFont(font);
mainMenu[5].setFillColor(sf::Color::White);
mainMenu[5].setString("CHARACTERS");
mainMenu[5].setCharacterSize(35);
mainMenu[5].setPosition(sf::Vector2f(600, 670));
mainMenu[5].setScale(.9, 1);
mainMenu[5].setOutlineThickness(.1);
mainMenu[5].setOutlineColor(Color::White);
mainMenuSelected = 0; //start from zero index (play)
mainMenu[6].setFont(font);
mainMenu[6].setFillColor(sf::Color::White);
mainMenu[6].setString("EXIT");
mainMenu[6].setCharacterSize(40);
mainMenu[6].setPosition(sf::Vector2f(600, 710));
mainMenu[6].setScale(.9, 1);
}
Main_menu::~Main_menu()
{
}
//***********Function of drawing main menu***************//
void Main_menu::draw(sf::RenderWindow& window)
{
for (int i = 0; i < 7; i++)
{
window.draw(mainMenu[i]);
}
}
//***********Function of moving up******************/
void Main_menu::moveUp()
{
if (mainMenuSelected - 1 >= -1) // check if not on the first item (play)
{
mainMenu[mainMenuSelected].setScale(.9, 1);
mainMenu[mainMenuSelected].setFillColor(sf::Color::White); //change the pervious item's color
mainMenuSelected--; //move to the upper item
if (mainMenuSelected == -1)
{
mainMenuSelected = 6;
}
mainMenu[mainMenuSelected].setFillColor(sf::Color::Blue); //change the new item's color
mainMenu[mainMenuSelected].setScale(1.2, 1);
}
}
//***********Function of moving down******************/
void Main_menu::moveDown()
{
if (mainMenuSelected + 1 <= Max_main_menu) //check if not on the last item (exit)
{
mainMenu[mainMenuSelected].setScale(.9, 1);
mainMenu[mainMenuSelected].setFillColor(sf::Color::White); //change the pervious item's color
mainMenuSelected++; //move to the lower item
if (mainMenuSelected == 7)
{
mainMenuSelected = 0;
}
mainMenu[mainMenuSelected].setFillColor(sf::Color::Blue); //change the new item's color
mainMenu[mainMenuSelected].setScale(1.2, 1);
}
}
//***********Function of moving up******************/
//***********start ******************/
//PlayerAnimation class
class Animation
{
public:
IntRect uv_Rect; //we use uv_rect to crop one texture properly
Animation(Texture* character, Vector2u ImageCount, float SwitchTime);
void update(int row, float deltaTime, bool face_right); //It is the function used to update the PlayerAnimation of the character in each frame
~Animation();
private:
Vector2u ImageCount; //number of rows and columns of image
Vector2u CurrentImage; //the index of the accessed image
float TotalTime, SwitchTime; //switch time:is the time taken to switch between two textures
};
Animation::Animation(Texture* character, Vector2u ImageCount, float SwitchTime)
{
this->ImageCount = ImageCount; //we use keyword "this" to differentiate between the private variable and the parameter
this->SwitchTime = SwitchTime; //we use keyword "this" to differentiate between the private variable and the parameter
TotalTime = 0; //we initialize the total time of PlayerAnimation to zero
CurrentImage.x = 0; //we access to the start point of the texture
uv_Rect.width = character->getSize().x / float(ImageCount.x); //calculate the width of a single texture
uv_Rect.height = character->getSize().y / float(ImageCount.y); //calculate the height of a single texture
}
Animation::~Animation() {
}
void Animation::update(int row, float deltaTime, bool face_right) //It is the function used to update the PlayerAnimation of the character in each frame
{
CurrentImage.y = row; //we initialize the current image on the y-axis to the index of the row to get the suitable texture for each specific movement
TotalTime += deltaTime; //we add the value of delta time to the current value of total time
if (TotalTime >= SwitchTime)
{
TotalTime -= SwitchTime; //we subtract the value of switch time from the Total time
CurrentImage.x++; //we access to the next texture after the switch is done
if (CurrentImage.x >= ImageCount.x) //when we reach the last point of the row , we return back to the start point
{
CurrentImage.x = 0;
}
}
if (face_right) //if the user presses left key,the image will be flipped
{
uv_Rect.left = CurrentImage.x * uv_Rect.width;
uv_Rect.width = abs(uv_Rect.width);
}
else
{
uv_Rect.left = (CurrentImage.x + 1) * abs(uv_Rect.width);
uv_Rect.width = -abs(uv_Rect.width);
}
uv_Rect.top = CurrentImage.y * uv_Rect.height;
}
//Player class
class Player
{
public:
Player(Texture* character, Vector2u ImageCount, float SwitchTime, float speed); //Note:we add the speed
//initializer list for object's PlayerAnimation
void update(float deltaTime, RenderWindow& window, int w, int x);
~Player();
Vector2f GetPosition()
{
return body.getPosition();
}
RectangleShape body;
private:
Animation PlayerAnimation; //Creating object
unsigned int row; //there is no index in negative
bool face_right;
float speed;
};
Player::Player(Texture* character, Vector2u ImageCount, float SwitchTime, float speed) : //Note:we add the speed
PlayerAnimation(character, ImageCount, SwitchTime) //initializer list for object's PlayerAnimation
{
this->speed = speed;
face_right = true;
body.setSize(Vector2f(bodysize.x, bodysize.y));
body.setTexture(character);
}
Player::~Player() {
}
void Player::update(float deltaTime, RenderWindow& window, int w, int x) //We used a window here to handle events
{
// inputs
bool left = false;
bool right = false;
bool jump = false;
Event event;
Vector2f movement(0, 0);
//Moving
if (Keyboard::isKeyPressed(Keyboard::Left))
{
movement.x -= speed * deltaTime; //to let the speed increase every frame in the left direction
left = true;
}
if (Keyboard::isKeyPressed(Keyboard::Right))
{
movement.x += speed * deltaTime; //to let the speed increase every frame in the right direction
right = true;
}
if ((Keyboard::isKeyPressed(Keyboard::Space))) //jumping without pressing any other key
{
jump = true;
}
if (movement.x == 0) //we access to row 0 when the character isn't moving
{
row = 0; //ideal position of the character
}
else
{
row = 1; //we access to row 1 when the character is moving
if (movement.x > 0)
face_right = true; //the character is moving rightwards
else
face_right = false; //the character is moving leftwards
}
// now update the velocity by...
pos += vel;
// ...updating gravity
vel += gravity;
// ...capping gravity
if (vel.y > maxfall)
vel.y = maxfall;
if (left) // running to the left
{
vel.x -= runacc;
}
else if (right)// running to the right
{
vel.x += runacc;
}
else // not running anymore; slowing down each frame
{
vel.x *= .0111;
}
// jumping left and rigth
if (jump)
{
if (left)
{
face_right = false;
row = 2;
}
if (right)
{
face_right = true;
row = 2;
}
if (right == false && left == false)
{
row = 3;
}
else if (jumpcounter > 0) { // first few frames in the air
vel.y += -.15;
jumpcounter--;
}
}
else // jump key released, stop acceleration
{
jumpcounter = 0;
}
// update the position
body.setPosition(pos);
PlayerAnimation.update(row, deltaTime, face_right);//calling update function from PlayerAnimation object
body.setTextureRect(PlayerAnimation.uv_Rect);
// for collision with steps
if (vel.y >= 0)
{
for (int i = 0; i < 1000; i++)
{
if ((pos.x - 0.6 * bodysize.x > floorlocation[i].x)
&& (pos.x - bodysize.x < floorlocation[i].x + floorlocation[i].w)
&& (pos.y + 0.5 * bodysize.y > floorlocation[i].y)
&& (pos.y + 0.5 * bodysize.y < floorlocation[i].y + floorlocation[i].h))
{
pos.x = pos.x;
vel.y = 0;
pos.y = floorlocation[i].y - 20;
scoree = i * 10;
if (Keyboard::isKeyPressed(Keyboard::Space))
{
vel.y += jumpacc * 4;
jumpcounter = jumpframes;
if (jumpcounter > 0) // first few frames in the air
{
vel.y += jumpacc;
jumpcounter--;
}
}
}
}
}
}
Sound sound_sot, sound_jump, sound_hello, sound_pose, sound_play, sound_coll;
void GameOver()
{
sf::RenderWindow window0(sf::VideoMode(600, 600), "SFML WORK!", Style::None);
sf::SoundBuffer tryAgain;
if (tryAgain.loadFromFile("falling.wav") == false)
{
//code here
}
sf::Sound t_again;
t_again.setBuffer(tryAgain);
t_again.play();
Texture T_GameOver;
T_GameOver.loadFromFile("images/Gover.png");
Sprite s_GameOver(T_GameOver);
std::fstream file;
std::string highS;
Text text9, text10, text11, text12;
Font font1;
font1.loadFromFile("font/actionj.ttf");
text9.setFont(font1); // to draw word "score : "
text9.setCharacterSize(60);
text9.setFillColor(sf::Color::White);
text9.setPosition(50, 420);
text10.setFont(font1); // to draw word "high score :"
text10.setCharacterSize(50);
text10.setFillColor(sf::Color::White);
text10.setPosition(50, 500);
text11.setFont(font1); // to draw word "player score number"
text11.setCharacterSize(60);
text11.setFillColor(sf::Color::White);
text11.setPosition(400, 420);
text12.setFont(font1); // to draw word "high score number"
text12.setCharacterSize(60);
text12.setFillColor(sf::Color::White);
text12.setPosition(450, 500);
while (window0.isOpen())
{
sf::Event event;
while (window0.pollEvent(event))
{
switch (event.type)
{
case sf::Event::KeyReleased:
switch (event.key.code)
{
case sf::Keyboard::Escape:
window0.close();
hid_menu = false;
hid = false;
end1 = false;
break;
}
break;
}
file.open("hadi.txt", ios::in);
getline(file, highS);
file.close();
highscoree = stoi(highS);
if ((scoree ) > highscoree)
{
highscoree = (scoree );
file.open("hadi.txt", std::ios::out);
file << highscoree << endl;
file.close();
}
text9.setString("score : ");
text10.setString("high score : ");
text11.setString(score_string);
text12.setString(highS);
}
window0.clear();
window0.draw(s_GameOver);
window0.draw(text11);
window0.draw(text12);
window0.draw(text10);
window0.draw(text9);
window0.display();
}
}
void how_to_play(RenderWindow& window)
{
Texture t_how_play;
t_how_play.loadFromFile("images/instructions.png");
Sprite s_how_play;
s_how_play.setTexture(t_how_play);
window.clear(Color(0, 0, 0));
window.draw(s_how_play);
window.display();
if (Keyboard::isKeyPressed(Keyboard::Escape))
{
hid_menu = false;
}
}
void profiel(RenderWindow& window)
{
Texture por;
por.loadFromFile("final.jpg");
Sprite s_por;
s_por.setTexture(por);
s_por.setScale(Vector2f(.562, .739));
window.clear(Color(0, 0, 0));
window.draw(s_por);
window.display();
if (Keyboard::isKeyPressed(Keyboard::Escape))
{
hid_menu = false;
}
}
void profiel_game(RenderWindow& window) {
Texture por_game;
por_game.loadFromFile("images/IMG_20210529_212726.jpg");
Sprite s_por_game;
s_por_game.setTexture(por_game);
window.clear();
window.draw(s_por_game);
window.display();
if (Keyboard::isKeyPressed(Keyboard::Escape))
{
hid_menu = false;
}
}
int main()
{
//logo
{
Texture logo;
logo.loadFromFile("images/GEN_172.jpg");
Sprite sp;
sp.setTexture(logo);
//sp.scale(0.4, 0.5); // My logo is quite big in fact (1st google result btw)
int logoWidth = sp.getGlobalBounds().width;
int logoHeight = sp.getGlobalBounds().height;
// With the logo loaded, I know its size, so i create the window accordingly
RenderWindow window(sf::VideoMode(logoWidth, logoHeight), "SFML", Style::None); // <- Important!! Style=None removes title
// To close splash window by timeout, I just suppose you want something like this, don't you?
Clock timer00;
Time time5 = timer00.restart();
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
// event loop is always needed
}
// Window closed by time
time5 += timer00.restart();
if (time5 >= sf::seconds(1.5f)) {
window.close();
}
window.clear();
window.draw(sp);
window.display();
}
}
/*****menue*******/
Texture t20, esc, b2, b3;
esc.loadFromFile("grey.png");
b2.loadFromFile("blue-sky-clouds_1417-1850.jpg");
Sprite escS(esc), b_2;
b_2.setTexture(b2);
b_2.setScale(Vector2f(2.5, 2.5));
t20.loadFromFile("back.jpg");
b3.loadFromFile("Screenshot (11).png");
Sprite back(t20), b30(b3);
back.setScale(Vector2f(.6, .8));
/* headddddddd */
RectangleShape player_head(Vector2f(355.0f, 500)), player_head_2(Vector2f(355.0f, 500)), player_head_3(Vector2f(355.0f, 500));
player_head.setPosition(350, -20);
Texture playertex_head, playertex_head_2, playertex_head_3;
playertex_head.loadFromFile("ju.png");
playertex_head_2.loadFromFile("ju.png");
playertex_head_3.loadFromFile("ju.png");
player_head.setTexture(&playertex_head);
player_head.setScale(Vector2f(.9, .9));
player_head_2.setTexture(&playertex_head);
player_head_2.setScale(Vector2f(.1, .1));
player_head_2.setPosition(560, 460);
player_head_3.setPosition(70, 0);
player_head_3.setScale(Vector2f(.9, .9));
player_head_3.setTexture(&playertex_head_3);
Animation ani_head(&playertex_head, Vector2u(8, 1), 0.1f);
Animation ani_head_2(&playertex_head_2, Vector2u(8, 1), 0.1f);
Animation ani_head_3(&playertex_head_3, Vector2u(8, 1), 0.1f);
int c0 = 460;
Clock clock02;
Texture por, por_game;
por_game.loadFromFile("images/IMG_20210529_212726.jpg");
por.loadFromFile("final.jpg");
Sprite s_por, s_por_game;
s_por.setTexture(por);
s_por.setScale(Vector2f(.562, .739));
s_por_game.setTexture(por_game);
/*photo sounddddddddd */
Texture music[7];
Texture sound[7];
for (int i = 0; i < 7; i++)
{
sound[i].loadFromFile(to_string(i) + ".png");
music[i].loadFromFile(to_string(i) + ".png");
}
int counter = 3;
Sprite musicsprite;
musicsprite.setTexture(music[counter]);
musicsprite.setPosition(680, 400);
musicsprite.setScale(Vector2f(.9, .8));
int counter2 = 3;
Sprite soundsprite;
soundsprite.setTexture(sound[counter2]);
soundsprite.setPosition(680, 500);
soundsprite.setScale(Vector2f(.9, .8));
Font font_sound;
font_sound.loadFromFile("font/Double_Bubble_shadow_italic.otf");
Text soundtext[3];
soundtext[0].setFont(font_sound);
soundtext[0].setString("MUSIC");
soundtext[0].setPosition(580, 415);
soundtext[0].setCharacterSize(30);
soundtext[0].setFillColor(sf::Color::Blue);
soundtext[0].setScale(1.2, 1);
soundtext[1].setFont(font_sound);
soundtext[1].setString("SOUND");
soundtext[1].setPosition(580, 515);
soundtext[1].setCharacterSize(30);
soundtext[2].setFont(font_sound);
soundtext[2].setString("BACK");
soundtext[2].setPosition(580, 600);
soundtext[2].setCharacterSize(30);
int sel = 0;
/* sounddddddddddd */
//////////////////////
SoundBuffer menu, play_game, jump, jump2, hello, pose, alarm;
menu.loadFromFile("menu.wav");
play_game.loadFromFile("Elevator Music - Gaming Background Music (HD).wav");
alarm.loadFromFile("19.wav");
jump2.loadFromFile("jump_mid.wav");
jump.loadFromFile("jump_lo.wav");
hello.loadFromFile("hello.wav");
pose.loadFromFile("pause.wav");
Sound sound_sot, sound_jump, sound_hello, sound_pose, sound_play, sound_coll, sound_alarm;
sound_alarm.setBuffer(alarm);
sound_coll.setBuffer(jump2);
sound_sot.setBuffer(menu);
sound_hello.setBuffer(hello);
sound_jump.setBuffer(jump);
sound_pose.setBuffer(pose);
sound_play.setBuffer(play_game);
sound_sot.setLoop(true);
sound_play.setLoop(true);
sound_sot.play();
sound_coll.setVolume(counter2 * 20);
sound_jump.setVolume(counter2 * 20);
sound_hello.setVolume(counter2 * 20);
sound_pose.setVolume(counter2 * 20);
sound_play.setVolume(counter2 * 5);
sound_sot.setVolume(counter * 20);
sound_alarm.setVolume(counter2 * 20);
/////////////////
/*select charecter*/
Text player_ch[4];
player_ch[0].setFont(font_sound);
player_ch[0].setString("player1");
player_ch[0].setPosition(580, 415);
player_ch[0].setCharacterSize(30);
player_ch[0].setFillColor(sf::Color::Blue);
player_ch[0].setScale(1.2, 1);
player_ch[1].setFont(font_sound);
player_ch[1].setString("player2");
player_ch[1].setPosition(580, 515);
player_ch[1].setCharacterSize(30);
player_ch[2].setFont(font_sound);
player_ch[2].setString("player3");
player_ch[2].setPosition(580, 600);
player_ch[2].setCharacterSize(30);
player_ch[3].setFont(font_sound);
player_ch[3].setString("back");
player_ch[3].setPosition(580,680);
player_ch[3].setCharacterSize(30);
player_ch[3].setFillColor(sf::Color::White);
player_ch[3].setScale(1.2, 1);
Texture player10, player20, player30;
player10.loadFromFile("images/ore3.png");
player20.loadFromFile("images/bayz3.png");
player30.loadFromFile("images/2smr3.png");
Sprite s_player10(player10), s_player20(player20), s_player30(player30);
s_player10.setPosition(700, 415);
s_player20.setPosition(700, 515);
s_player30.setPosition(700, 620);
s_player10.setScale(.5, .7);
s_player20.setScale(.5, .7);
s_player30.setScale(.5, .7);
/******exitttttt********/
/**/
sf::Texture icy;
icy.loadFromFile("eximmmm2 (1).png");
sf::Sprite icyshape;
icyshape.setTexture(icy);
icyshape.setScale(Vector2f(.7, .7));
icyshape.setPosition(190, 180);
Font font20;
font20.loadFromFile("font/Chocolate Bar Demo.otf");
sf::Text text0;
text0.setFont(font20);
text0.setString("Are you sure to exit?");
text0.setFillColor(sf::Color(0, 0, 200));
text0.setPosition(365.0f, 350.0f);
text0.setScale(Vector2f(1.2, 1));
sf::Text yes_no[2];
yes_no[0].setFont(font20);
yes_no[0].setString("Yes");
yes_no[0].setPosition(400, 480);
yes_no[0].setFillColor(sf::Color::Blue);
yes_no[0].setScale(1.2, 1);
yes_no[1].setFont(font20);
yes_no[1].setString("NO");
yes_no[1].setPosition(655, 485);
yes_no[1].setFillColor(sf::Color::White);
yes_no[1].setScale(.9, 1);
int sel_yes_no = 0;
sf::Text yes_no2[3];
yes_no2[0].setFont(font20);
yes_no2[0].setString("Yes");
yes_no2[0].setPosition(400, 480);
yes_no2[1].setFont(font20);
yes_no2[1].setString("No");
yes_no2[1].setPosition(655, 485);
yes_no2[1].setFillColor(sf::Color::White);
yes_no2[1].setScale(.9, 1);
int sel_yes_no2 = 2;
/*****end exit******/
/**********play gamee********************/
Texture tbackground, tleftborder, trightborder;
Texture tstep2, tstep3, tstep4, tstep5;
Sprite sbackground, sleftborder, srightborder; //for background , charcter ,left border& right border
Texture icy_man; //for charcter
icy_man.loadFromFile("images/oregenal.png"); //load the charcter
tbackground.loadFromFile("images/545.png"); //load background
trightborder.loadFromFile("R1.png");// load right border
tleftborder.loadFromFile("L1.png");//load left border
tstep2.loadFromFile("1 (1).png"); //load the second steps
tstep3.loadFromFile("1 (9).png"); //load the second steps
tstep4.loadFromFile("1 (8).png"); //load the second steps
tstep5.loadFromFile("1 (talg).png"); //load the second steps
View view(FloatRect(0, 0, sd.x, sd.y)); //to move screen
View view2(FloatRect(0, 0, sd.x, sd.y)); //to fixed things
// all the texture
Texture tstep0, ColckTextuer, tbackground2, thurryup, tmountanes, tgameover; //for the first four steps
ColckTextuer.loadFromFile("Clock.png"); //load the cclock texter
tbackground.setRepeated(true); //for repeating background
tbackground2.setRepeated(true); //for repeating background
trightborder.setRepeated(true); //for repeated right border
tleftborder.setRepeated(true);//for repeated left border
//texture for charcter
Vector2u T_size = icy_man.getSize();
Player player1(&icy_man, Vector2u(4, 6), 0.4, 100); //creating an object from player class
//all the sprites and rectangel shape
RectangleShape step2, ColckRectangl, step3, step4, step5;
step2.setTexture(&tstep2);
step3.setTexture(&tstep3);
step4.setTexture(&tstep4);
step5.setTexture(&tstep5);
//clock PlayerAnimation
Animation ColckAnimationOpject(&ColckTextuer, Vector2u(15, 1), 1.05f);
ColckRectangl.setTexture(&ColckTextuer);
ColckRectangl.setSize(Vector2f(90, 90));
ColckRectangl.setPosition(0, 0);
RectangleShape vie, vie2, vie3;
vie.setSize(Vector2f(1640, .000001));
vie2.setSize(Vector2f(1000, 0.5));
vie3.setSize(Vector2f(1640, 0.000001));
vie.setPosition(0, 300);
vie2.setPosition(0, 880);
vie3.setPosition(0, 940);
//sprites
Sprite sbackground2;
sbackground2.setTexture(tbackground2); //to load background in sprite
sbackground.setTexture(tbackground); //to load background in sprite
srightborder.setTexture(trightborder); //load right border in sprite
sleftborder.setTexture(tleftborder); //load left border in sprite
sleftborder.setPosition(1000, 0); //Make its starting point at the bottom left of the screen
srightborder.setPosition(0, 0);//Make its starting point at the bottom right of the screen
//all fonts
Font font1,font2 ,font3;
font2.loadFromFile("font/BEYONDCONTROL.ttf");
font3.loadFromFile("font/Cartoon Blocks Christmas.otf");
font1.loadFromFile("MATURASC.ttf");
//all texts
Text text1, text2, text3, text4, text5, text6, text7;
//text1
text1.setFont(font2); // to draw word "hurry up"
text1.setString("hurry up"); //to load the word hurry up
text1.setCharacterSize(100); // in pixels, not points!
text1.setFillColor(sf::Color::Yellow);
//text2
text2.setFont(font2);
text2.setCharacterSize(30); // in pixels, not points!
text2.setFillColor(sf::Color::Black); //to set the color of the word hurry up
//text3
text3.setFont(font3);
text3.setCharacterSize(50); // in pixels, not points!
text3.setFillColor(sf::Color::Color(0, 0, 0)); //to set the color of the word hurry up
text3.setPosition(10, 730);
text3.setString("Score : ");
//text4
text4.setFont(font3);
text4.setCharacterSize(50); // in pixels, not points!
text4.setFillColor(sf::Color::Color(0,0,0)); //to set the color of the word hurry up
text4.setPosition(200, 730);
text5.setFont(font1); // to draw word "hurry up"
text5.setString("cool "); //to load the word hurry up
text5.setCharacterSize(100); // in pixels, not points!
text5.setFillColor(sf::Color::Yellow);
//all times and clocks
Clock clock/*for clock*/, clock3/*for text1*/;
Clock c, z; //Clock2
int vy = -2.5; //velocity of view of y axis
int y = 1000; //for repeating background
int h = 100000; //variable for repeating backgrond upward
FloatRect fBounds(0.f, 0.f, sd.x, sd.y); // arbitrary > view height
IntRect iBounds(fBounds);
int num = 0;
int a = 0;
float deltaTime_clock = 0.0f;
while (true)
{
ShowWindow(GetConsoleWindow(), SW_HIDE);
sf::RenderWindow window(VideoMode(1080, 800), "SF1MMake_Menu");
Main_menu menu(500, 500);
//Setting the framerate limit to 60 FPS
window.setFramerateLimit(85);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
/*****start move menu******/
if (hid_menu == false)
{
if (event.type == sf::Event::KeyPressed)
{
if (event.key.code == sf::Keyboard::Up)
{
menu.moveUp(
);
if (c0 >= 460)
{
if (c0 == 460)
c0 = 740;
c0 = c0 - 40;
}