forked from Rustam-Z/cpp-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patholaf-game.cpp
More file actions
199 lines (167 loc) · 4.83 KB
/
Copy patholaf-game.cpp
File metadata and controls
199 lines (167 loc) · 4.83 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
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <iostream>
#include <windows.h>
#include <cstdlib>
#include <conio.h>
#include <ctime>
using namespace std;
//Calculators
int k;
// Logical Calculations
int Rand, Case_1 = 0, Case_2 = 0, x, Turn_1, Turn_2, TURN_1, TURN_2;
//Window style
sf::RenderWindow window(sf::VideoMode(1000, 650), "OLAF Game", sf::Style::Close | sf::Style::Resize);
//identifires of Game
sf::RectangleShape MainMenu(sf::Vector2f(1000.0f, 650.0f));
sf::RectangleShape Developers(sf::Vector2f(1000.0f, 650.0f));
sf::RectangleShape Help(sf::Vector2f(1000.0f, 650.0f));
sf::RectangleShape Quit(sf::Vector2f(1000.0f, 650.0f));
sf::RectangleShape Loading_1(sf::Vector2f(1000.0f, 650.0f));
sf::RectangleShape Loading_2(sf::Vector2f(1000.0f, 650.0f));
sf::RectangleShape Loading_3(sf::Vector2f(1000.0f, 650.0f));
sf::RectangleShape Map(sf::Vector2f(1000.0f, 650.0f));
sf::RectangleShape Player(sf::Vector2f(45.0f, 30.0f));
//Music
//sf::SoundBuffer Rington; sf::Sound sound_Rington;
//sf::SoundBuffer BackMusic; sf::Sound sound_BackMusic;
//Functions
void F_MainMenu();
void F_Help();
void F_Developers();
void F_Quit();
void F_Start();
void F_Logic();
void F_Map();
void F_MainMenu() {
window.clear(sf::Color::White);
window.draw(MainMenu);
window.display();
//Start Game
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Numpad1)) {
//sound_Rington.play();
F_Start();
}
//Help Desck
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Numpad2)) {
//sound_Rington.play();
F_Help();
}
//Developers
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Numpad3)) {
//sound_Rington.play();
F_Developers();
}
//Quit
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Numpad4)) {
//sound_Rington.play();
F_Quit();
}
}
void F_Help() {
window.clear(sf::Color::White);
window.draw(Help);
window.display();
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Escape))
{
//sound_Rington.play();
F_MainMenu();
}
else { F_Help(); }
}
void F_Developers() {
window.clear(sf::Color::White);
window.draw(Developers);
window.display();
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Escape)) {
//sound_Rington.play(); F_MainMenu();
}
else { F_Developers(); }
}
void F_Quit() {
window.clear(sf::Color::White);
window.draw(Quit);
window.display();
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Numpad2)) {
//sound_Rington.play();
F_MainMenu();
}
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Numpad1))
{
//sound_Rington.play();
system("pause");
window.close();
}
else { F_Quit(); }
}
void F_Start() {
F_Map();
if ((x % 2 == 0) && sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Space)) {
//sound_Rington.play();
window.clear();
window.display();
Sleep(0700); Sleep(0700); Sleep(0700);
x++;
F_Logic();
F_Start();
}
else if (x % 2 == 1) {
//sound_Rington.play();
window.clear();
window.display();
Sleep(0700); Sleep(0700); Sleep(0700);
x++;
F_Logic();
F_Start();
}
else F_Start();
}
void F_Loading() {
for (int i = 1; i <= 12; i++) {
window.clear(sf::Color::White);
if (i == 1 || i == 4 || i == 7 || i == 10) window.draw(Loading_1);
if (i == 2 || i == 5 || i == 8 || i == 11) window.draw(Loading_2);
if (i == 3 || i == 6 || i == 9 || i == 12) window.draw(Loading_3);
window.display();
Sleep(0700);
}
}
//main part
int main()
{
k = 0;
//Identifiers Picture
sf::Texture TextMainMenu; TextMainMenu.loadFromFile("Main_Menu.jpg"); MainMenu.setTexture(&TextMainMenu);
sf::Texture TextHelp; TextHelp.loadFromFile("Help.jpg"); Help.setTexture(&TextHelp);
sf::Texture TextDevelopers; TextDevelopers.loadFromFile("Developers.jpg"); Developers.setTexture(&TextDevelopers);
sf::Texture TextQuit; TextQuit.loadFromFile("Quit_Main.jpg"); Quit.setTexture(&TextQuit);
sf::Texture TextLoading1; TextLoading1.loadFromFile("Loading1.jpg"); Loading_1.setTexture(&TextLoading1);
sf::Texture TextLoading2; TextLoading2.loadFromFile("Loading2.jpg"); Loading_2.setTexture(&TextLoading2);
sf::Texture TextLoading3; TextLoading3.loadFromFile("Loading3.jpg"); Loading_3.setTexture(&TextLoading3);
sf::Texture TextMap; TextMap.loadFromFile("Map.png"); Map.setTexture(&TextMap);
sf::Texture TextPlayer_1; TextPlayer_1.loadFromFile("Player.png"); Player.setTexture(&TextPlayer_1);
// Musics
//if (!Rington.loadFromFile("Rington.wav")) { cout << "ERROR" << endl; } sound_Rington.setBuffer(Rington);
//if (!BackMusic.loadFromFile("BackMusic.wav")) { cout << "ERROR" << endl; } sound_BackMusic.setBuffer(BackMusic);
//Starting point
while (window.isOpen())
{
sf::Event evnt;
while (window.pollEvent(evnt))
{
switch (evnt.type) {
case sf::Event::Closed: window.close();
break;
case sf::Event::Resized:;
break;
}
}
//Others
// Outputs
if (k == 0) {// sound_BackMusic.play();
F_Loading(); k++; }
//k = 1;
if (k == 1) { F_MainMenu(); }
}
return 0;
}