-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyPrint.h
333 lines (316 loc) · 6.63 KB
/
MyPrint.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
#pragma once
#include "Macros.h"
// prints the game's starting welcome page
#pragma warning (disable:4996)
int Console_rows;
int Console_cols;
int intro = 0;
void printmenu();
void newgame();
//gets the current console windows size
void console_size() {
CONSOLE_SCREEN_BUFFER_INFO csbi;;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
Console_cols = csbi.srWindow.Right - csbi.srWindow.Left + 1;
Console_rows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
}
//prints game's welcome page at program start
void printwlc() {
console_size();
SetCursorPos(1, 1);
int i;
for (i = 0; i < (Console_cols * Console_rows); i++) {
printf(BBlue Diamond);
}
if (i == (Console_cols * Console_rows)) {
printf("\u001b[28A");
i -= 5851;
printf("\u001b[103D");
i -= 98;
if (i == 5755)
// Wellcome length = 16
{
for (int j = 0; j < 8; j++) {
Sleep(250);
printf("\b");
printf(" ");
printf("\u001b[1D");
}
Sleep(100);
//printf("\x1b[31m");
printf(BRed W);
Sleep(100);
printf(BRed E);
Sleep(100);
printf(BRed L);
Sleep(100);
printf(BRed L);
Sleep(100);
printf(BRed C);
Sleep(100);
printf(BRed O);
Sleep(100);
printf(BRed M);
Sleep(100);
printf(BRed E);
//}
printf("\u001b[1B");
i += 209;
printf("\u001b[3D");
i -= 7;
for (int k = 0; k < 2; k++) {
Sleep(250);
printf("\b");
printf(" ");
printf("\u001b[1D");
}
if (i == 5957)//5938
{
Sleep(100);
printf(BYellow T);
Sleep(100);
printf(BYellow O);
}
printf("\u001b[1B");
i += 209;
printf("\u001b[7C");
i -= 17;
for (int j1 = 0; j1 < 16; j1++) {
Sleep(250);
printf("\b");
printf(" ");
printf("\u001b[1D");
}
if (i == 6149)//6130
{
Sleep(100);
printf(BRed M);
Sleep(100);
printf(BRed I);
Sleep(100);
printf(BRed N);
Sleep(100);
printf(BRed E);
Sleep(100);
printf(BRed S);
Sleep(100);
printf(BRed W);
Sleep(100);
printf(BRed E);
Sleep(100);
printf(BRed E);
Sleep(100);
printf(BRed P);
Sleep(100);
printf(BRed E);
Sleep(100);
printf(BRed R);
Sleep(100);
printf(" ");
Sleep(100);
printf(BRed G);
Sleep(100);
printf(BRed A);
Sleep(100);
printf(BRed M);
Sleep(100);
printf(BRed E);
}
}
}
gotoxy(122, 50);
for (int j2 = 0; j2 < 35; j2++) {
Sleep(125);
printf("\b");
printf(" ");
printf("\u001b[1D");
}
printf("Please Press Any key to Continue...");
getch();
}
//gets the user profile name and call for a save in a file
void profile() {
/*char Profile_Name[20] = {};*/
/*struct Login lg;*/
/*int index = readindex();
char str[32];
Sleep(1);
int i = index;*/
/*lg[i].Name = str;*/
char Name[32] = {};
Retry: while (Name[0] == '\0' || Name[1] == '\0') {
system("cls");
gotoxy(95, 28);
printf("\u001b[32;1mPlease Enter Your Name: ");
/*scanf("%[^�n�]s", &Profile_Name);*/
gets_s(Name);
if (strlen(Name) <= 1) {
system("cls");
gotoxy(95, 28);
printf("\u001b[31;1mUser Name is not Valid.");
Sleep(2000);
goto Retry;
}
}
/*writeindex(i);*/
WritetomyFile(Name);
gotoxy(1, 55);
printf("\n \x1b[37mUser Profile Was Created Successfully.");
Sleep(1500);
system("cls");
printmenu ();
}
// prints Main menu
void printmenu() {
int choice;
repmenu: system("cls");
gotoxy(95, 20);
printf(BWhite Gamer " ");
readfile("C:\\Users\\Kebabist\\source\\repos\\Takhribchi\\UserProfiles.txt");
printf(" " BWhite Gamer) ;
gotoxy(95, 25);
printf("\u001b[36;1m1. User records");
gotoxy(95, 26);
printf("\u001b[36;1m2. New Game");
gotoxy(95, 27);
printf("\u001b[36;1m3. Change User");
gotoxy(95, 28);
printf("\u001b[36;1m4. Exit");
gotoxy(95, 29);
printf("\u001b[1m\u001b[35;1mEnter your choice : ");
gotoxy(116, 29);
while (1) {
scanf("%d", &choice);
if (choice == 0 ||choice == EOF || choice == '\n' || choice > 10 || choice < 0) {
while (getchar() != '\n');
system("cls");
gotoxy(95, 28);
printf("\x1b[31mPlease Enter a valid number!");
Sleep(2000);
goto repmenu;
}
else {
switch (choice)
{
case 1:
system("cls");
gotoxy(90, 28);
readfile("C:\\Users\\Kebabist\\source\\repos\\Takhribchi\\UserProfiles.txt");
gotoxy(85, 50);
printf("Please Press Any key to go bacck to Main Menu");
getch();
goto repmenu;
break;
case 2:
system("cls");
newgame();
break;
case 3:
system("cls");
while (getchar() != '\n') { system("cls"); }
profile();
break;
case 4:
system("cls");
gotoxy(95, 28);
printf(BYellow "Have Fun!!!" RESET);
_exit(0);
break;
default:
system("cls");
gotoxy(95, 28);
printf("\x1b[31mPlease Enter a valid number!");
Sleep(2500);
goto repmenu;
break;
}
}
}
}
//prints newgame menu
void newgame() {
while (getchar() != '\n');
fflush(stdin); // clearing buffer
int choice;
repnewgame: system("cls");
gotoxy(95, 25);
printf("\u001b[36;1m1. Continue");
//gotoxy(95, 26);
//printf("\u001b[36;1m2. Intermediate 16X16");
//gotoxy(95, 27);
//printf("\u001b[36;1m3. Expert 30X16");
//gotoxy(95, 28);
//printf("\u001b[36;1m4. Veteran");
gotoxy(95, 26);
printf("\u001b[36;1m2. Main Menu");
gotoxy(95, 27);
printf("\u001b[1m\u001b[35;1mEnter your choice : ");
while (1) {
scanf("%d", &choice);
if (choice == 0 || choice == EOF || choice == '\n' || choice > 10 || choice < 0) {
while (getchar() != '\n');
system("cls");
gotoxy(95, 28);
printf("\x1b[31mPlease Enter a valid number!");
Sleep(2000);
goto repnewgame;
}
else {
switch (choice)
{
case 1:
system("cls");
Logic();
break;
// case 2:
// system("cls");
// Logic(16, 16, 16);
// break;
// case 3:
// system("cls");
// Logic(30, 16, 21);
// break;
// case 4:
//revet: system("cls");
// int r, c;
// printf("please Enter number of Rows: ");
// scanf("%d", &r);
// printf("please Enter number of Columns: ");
// scanf("%d", &c);
// //printf("please Enter number of Mines: ");
// //scanf("%d", &m);
// if (r < 1 || c < 1 ) {
// while (getchar() != '\n');
// system("cls");
// gotoxy(95, 28);
// printf("\x1b[31mPlease Enter a valid numbers!");
// Sleep(2500);
// goto revet;
// }
// Logic(r, c, 30);
// break;
case 2:
system("cls");
while (getchar() != '\n');
printmenu();
break;
default:
system("cls");
gotoxy(95, 28);
printf("\x1b[31mPlease Enter a valid number!");
Sleep(2500);
goto repnewgame;
break;
}
}
}
intro = 1;
}
//void gotoxy(int x, int y)
//{
// cord.X = x;
// cord.Y = y;
// SetConsoleCursorPosition(
// GetStdHandle(STD_OUTPUT_HANDLE),
// cord);
//}