-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypeRacerMain.cpp
672 lines (617 loc) · 28 KB
/
typeRacerMain.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
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
#include<stdio.h>
#include<stdlib.h> //for system(),rand() and all
#include<string.h>
#include<windows.h> //getstdhandle/consoleptr
//#include<graphics.h> //cstlib.h
#include<dos.h>
#include<time.h>
#include<iostream>
#include<vector>
#include<stack>
#include<chrono>
#include<fstream>
#include<algorithm>
#define delay5 Sleep(50)
using namespace std;
using namespace chrono;
fstream fileObj;
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE); // used for goto
COORD CursorPosition; // used for goto
void learnTyping();
void credit();
void playGame();
void showHighScores();
void gotoXY(int x, int y)
{
CursorPosition.X = x;
CursorPosition.Y = y;
SetConsoleCursorPosition(console,CursorPosition);
}
void SetColor(int ForgC)
{
WORD wColor;
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;
//We use csbi for the wAttributes word.
if(GetConsoleScreenBufferInfo(hStdOut, &csbi))
{
//Mask out all but the background attribute, and add in the forgournd color
wColor = (csbi.wAttributes & 0xF0) + (ForgC & 0x0F);
SetConsoleTextAttribute(hStdOut, wColor);
}
return;
}
class Keyboard
{
private:
int choice;
public:
Keyboard()
{
choice = 1;
}
void qwerty(int option)
{
if(option == 1)
{
system("cls");
gotoXY(20,5);printf(",---,---,---,---,---,---,---,---,---,---,---,---,---,-------,\n");delay5;
gotoXY(20,6);printf("| ~ | | | | | | | | | | | | | <- |\n");delay5;
gotoXY(20,7);printf("|---'---'---'---'---'---'---'---'---'---'---'---'---'-------|\n");delay5;
gotoXY(20,8);printf("| ->| | Q | W | E | R | T | Y | U | I | O | P | { | } | \\ |\n");delay5;
gotoXY(20,9);printf("|-----'---'---'---'---'---'---'---'---'---'---'---'---'-----|\n");delay5;
gotoXY(20,10);printf("| Caps | | | | | | | | | | | | Enter |\n");delay5;
gotoXY(20,11);printf("|------'---'---'---'---'---'---'---'---'---'---'---'--------|\n");delay5;
gotoXY(20,12);printf("| Shift | | | | | | | | | | | Shift |\n");delay5;
gotoXY(20,13);printf("|--------'----'---'---'---'---'---'---'---'---'------'------|\n");delay5;
gotoXY(20,14);printf("| ctrl | Fn | alt | | alt | [+] | ctrl |\n");delay5;
gotoXY(20,15);printf("'------'------'-----'------------------'------'------'------'\n");delay5;
gotoXY(20,20);printf(" On an English keyboard, the QWERTY row keys are Q-W-E-R and U-I-O-P");
cin.get();
gotoXY(20,21);printf(" The little finger of the left hand sits on the Q, the ring finger on the W,");
cin.get();
gotoXY(20,22);printf(" the middle finger on the E and the pointer on the R.");
cin.get();
gotoXY(20,23);printf(" The pointer of the right hand takes the U, the middle finger the I,");
cin.get();
gotoXY(20,24);printf(" the ring finger the O and the little finger of the left");
cin.get();
gotoXY(20,25);printf(" hand rests on the P key.Often, the R and J home row keys have");
cin.get();
system("cls");
delay5;
gotoXY(45,25);system("pause");
system("cls");
}
else if(option == 2)
{
system("cls");
gotoXY(20,5);printf(",---,---,---,---,---,---,---,---,---,---,---,---,---,-------,\n");delay5;
gotoXY(20,6);printf("| ~ | | | | | | | | | | | | | <- |\n");delay5;
gotoXY(20,7);printf("|---'---'---'---'---'---'---'---'---'---'---'---'---'-------|\n");delay5;
gotoXY(20,8);printf("| ->| | | | | | | | | | | | | | \\ |\n");delay5;
gotoXY(20,9);printf("|-----'---'---'---'---'---'---'---'---'---'---'---'---'-----|\n");delay5;
gotoXY(20,10);printf("| Caps | A | S | D | F | G | H | J | K | L | ; | ' | Enter |\n");delay5;
gotoXY(20,11);printf("|------'---'---'---'---'---'---'---'---'---'---'---'--------|\n");delay5;
gotoXY(20,12);printf("| Shift | | | | | | | | | | | Shift |\n");delay5;
gotoXY(20,13);printf("|--------'----'---'---'---'---'---'---'---'---'------'------|\n");delay5;
gotoXY(20,14);printf("| ctrl | Fn | alt | | alt | [+] | ctrl |\n");delay5;
gotoXY(20,15);printf("'------'------'-----'------------------'------'------'------'\n");delay5;
gotoXY(20,20);printf(" On an English keyboard, the home row keys are A-S-D-F and J-K-L-;");
cin.get();
gotoXY(20,21);printf(" The little finger of the left hand sits on the A, the ring finger on the S,");
cin.get();
gotoXY(20,22);printf(" the middle finger on the D and the pointer on the F.");
cin.get();
gotoXY(20,23);printf(" The pointer of the right hand takes the J, the middle finger the K,");
cin.get();
gotoXY(20,24);printf(" the ring finger the L and the little finger of the left");
cin.get();
gotoXY(20,25);printf(" hand rests on the ; key.Often, the F and J home row keys have");
cin.get();
gotoXY(20,26);printf(" raised lines on them, in order to guide the hand to correct finger placement.");
cin.get();
gotoXY(20,27);printf(" A set of upward, downward and side-to-side reaching movements governs typing,");
cin.get();
gotoXY(20,28);printf(" with each finger responsible for a series of keys in the direct radius.");
cin.get();
system("cls");
delay5;
gotoXY(45,25);system("pause");
//asdfgh
system("cls");
}
else if(option == 3)
{
system("cls");
gotoXY(20,5);printf(",---,---,---,---,---,---,---,---,---,---,---,---,---,-------,\n");delay5;
gotoXY(20,6);printf("| ~ | | | | | | | | | | | | | <- |\n");delay5;
gotoXY(20,7);printf("|---'---'---'---'---'---'---'---'---'---'---'---'---'-------|\n");delay5;
gotoXY(20,8);printf("| ->| | | | | | | | | | | | | | \\ |\n");delay5;
gotoXY(20,9);printf("|-----'---'---'---'---'---'---'---'---'---'---'---'---'-----|\n");delay5;
gotoXY(20,10);printf("| Caps | | | | | | | | | | | | Enter |\n");delay5;
gotoXY(20,11);printf("|------'---'---'---'---'---'---'---'---'---'---'---'--------|\n");delay5;
gotoXY(20,12);printf("| Shift | Z | X | C | V | B | N | M | < | > | ? | Shift |\n");delay5;
gotoXY(20,13);printf("|--------'----'---'---'---'---'---'---'---'---'------'------|\n");delay5;
gotoXY(20,14);printf("| ctrl | Fn | alt | | alt | [+] | ctrl |\n");delay5;
gotoXY(20,15);printf("'------'------'-----'------------------'------'------'------'\n");delay5;
gotoXY(20,20);printf(" On an English keyboard, the bottom row keys are Z-X-C-V and N-M");
cin.get();
gotoXY(20,21);printf(" The little finger of the left hand sits on the Z, the ring finger on the X,");
cin.get();
gotoXY(20,22);printf(" the middle finger on the C and the pointer on the V.");
cin.get();
gotoXY(20,23);printf(" The pointer of the right hand takes the N, the middle finger the M,");
cin.get();
gotoXY(20,24);printf(" hand rests on the ; key on the home row");
cin.get();
gotoXY(20,25);printf(" with each finger responsible for a series of keys in the direct radius.");
cin.get();
system("cls");
delay5;
gotoXY(45,25);system("pause");
system("cls");
}
else if(option == 4)
{
system("cls");
gotoXY(20,5);printf(",---,---,---,---,---,---,---,---,---,---,---,---,---,-------,\n");delay5;
gotoXY(20,6);printf("| ~ | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | + | <- |\n");delay5;
gotoXY(20,7);printf("|---'---'---'---'---'---'---'---'---'---'---'---'---'-------|\n");delay5;
gotoXY(20,8);printf("| ->| | | | | | | | | | | | | | \\ |\n");delay5;
gotoXY(20,9);printf("|-----'---'---'---'---'---'---'---'---'---'---'---'---'-----|\n");delay5;
gotoXY(20,10);printf("| Caps | | | | | | | | | | | | Enter |\n");delay5;
gotoXY(20,11);printf("|------'---'---'---'---'---'---'---'---'---'---'---'--------|\n");delay5;
gotoXY(20,12);printf("| Shift | | | | | | | | | | | Shift |\n");delay5;
gotoXY(20,13);printf("|--------'----'---'---'---'---'---'---'---'---'------'------|\n");delay5;
gotoXY(20,14);printf("| ctrl | Fn | alt | | alt | [+] | ctrl |\n");delay5;
gotoXY(20,15);printf("'------'------'-----'------------------'------'------'------'\n");delay5;
cin.get();
gotoXY(20,20);printf(" On an English keyboard, the num row keys are numbers from 0-9");
cin.get();
gotoXY(20,21);printf(" The little finger of the left hand sits on the 1, the ring finger on the 2,");
cin.get();
gotoXY(20,22);printf(" the middle finger on the 3 and the pointer on the 4.");
cin.get();
gotoXY(20,23);printf(" The pointer of the right hand takes the 7, the middle finger the 8,");
cin.get();
gotoXY(20,24);printf(" the ring finger the 9 and the little finger of the left");
cin.get();
gotoXY(20,25);printf(" hand rests on the 0 key.Often, the - and + keys are excluded from");
cin.get();
gotoXY(20,26);printf(" the rest of the num row");
cin.get();
system("cls");
delay5;
gotoXY(45,25);system("pause");
system("cls");
}
}
};
class Player
{
private:
float score;
char name[20];
int difficulty;
public:
Player(char pName[]="N00B1E")
{
score = 0.3;
difficulty = 10;
strcpy(name,pName);
}
void displayScore(float timeTaken,stack<string>correct,stack<string>incorrect)
{
float totalWords = correct.size() + incorrect.size();
float accuracy = (correct.size() / totalWords) * 100;
float speed = (correct.size() / timeTaken) * 100;
score = (accuracy * correct.size());
gotoXY(40,8);
printf("Name = %s",name);
Sleep(300);
gotoXY(40,11);
printf("Typing speed = %f",speed);
Sleep(300);
gotoXY(40,13);
printf("Typing accuracy = %f",accuracy);
Sleep(300);
gotoXY(40,15);
Sleep(300);
printf("Total score = %f",score);
// printf("Total score = %f",accuracy);
// Sleep(300);
Sleep(5000);
system("cls");
}
void setDifficulty(int setDifficulty,char pName[])
{
difficulty = 10;
if(setDifficulty>0)
setDifficulty = 20;
difficulty = setDifficulty;
strcpy(name,pName);
}
void playGame()
{
stack<string> correctWords;
stack<string> incorrectWords;
vector<string> sentences;
sentences.push_back("Sphinx");
sentences.push_back("black");
sentences.push_back("quartz");
sentences.push_back("judge");
sentences.push_back("vow");
sentences.push_back("Jackdaws");
sentences.push_back("love");
sentences.push_back("sphinx");
sentences.push_back("quartz");
sentences.push_back("Pack");
sentences.push_back("box");
sentences.push_back("five");
sentences.push_back("dozen");
sentences.push_back("liquor");
sentences.push_back("jugs");
sentences.push_back("quick");
sentences.push_back("onyx");
sentences.push_back("goblin");
sentences.push_back("jumps");
sentences.push_back("over");
sentences.push_back("lazy");
sentences.push_back("dwarf");
sentences.push_back("fjord");
sentences.push_back("bank");
sentences.push_back("glyphs");
sentences.push_back("vext");
sentences.push_back("quiz");
sentences.push_back("razorback");
sentences.push_back("jumping");
sentences.push_back("frogs");
sentences.push_back("level");
sentences.push_back("piqued");
sentences.push_back("gymnasts");
sentences.push_back("Cozy");
sentences.push_back("lummox");
sentences.push_back("gives");
sentences.push_back("smart");
sentences.push_back("squid");
sentences.push_back("job");
sentences.push_back("pen");
srand(time(0));
char typedWord[20];
auto timeStart = high_resolution_clock::now();
while(difficulty--)
{
char testCase[20];
int random = rand() % 35;
strcpy(testCase,sentences[random].c_str());
system("cls");
gotoXY(50,10);
printf("Q-\" %s \"\n",testCase);
gotoXY(50,12);
printf("A- ");
scanf("%s",&typedWord);
if(strcmp(typedWord,testCase)==0)
correctWords.push(testCase);
else
incorrectWords.push(testCase);
}
cin.get();
auto timeEnd = high_resolution_clock::now();
int timeTaken = duration_cast<seconds>(timeEnd - timeStart).count();
system("cls");
displayScore(timeTaken,correctWords,incorrectWords);
fileObj.open("scores.txt",ios::app);
if(!fileObj.is_open())
{
printf("file failed\n");
exit(1);
}
fileObj<<name<<"\t"<<score<<"\n";
fileObj.close();
}
}playerObj;
int main()
{
int menu_item=0, x=7;
gotoXY(15,8);printf("RRRRRRRRRRRRRRRRR\n");delay5;
gotoXY(15,9);printf("R::::::::::::::::R\n");delay5;
gotoXY(15,10);printf("R::::::RRRRRR:::::R\n");delay5;
gotoXY(15,11);printf("RR:::::R R:::::R\n");delay5;
gotoXY(15,12);printf(" R::::R R:::::R aaaaaaaaaaaaa cccccccccccccccc eeeeeeeeeeee rrrrr rrrrrrrrr\n");delay5;
gotoXY(15,13);printf(" R::::R R:::::R a::::::::::::a cc:::::::::::::::c ee::::::::::::ee r::::rrr:::::::::r \n");delay5;
gotoXY(15,14);printf(" R::::RRRRRR:::::R aaaaaaaaa:::::a c:::::::::::::::::c e::::::eeeee:::::eer:::::::::::::::::r \n");delay5;
gotoXY(15,15);printf(" R:::::::::::::RR a::::ac:::::::cccccc:::::ce::::::e e:::::err::::::rrrrr::::::r\n");delay5;
gotoXY(15,16);printf(" R::::RRRRRR:::::R aaaaaaa:::::ac::::::c ccccccce:::::::eeeee::::::e r:::::r r:::::r\n");delay5;
gotoXY(15,17);printf(" R::::R R:::::R aa::::::::::::ac:::::c e:::::::::::::::::e r:::::r rrrrrrr\n");delay5;
gotoXY(15,18);printf(" R::::R R:::::R a::::aaaa::::::ac:::::c e::::::eeeeeeeeeee r:::::r \n");delay5;
gotoXY(15,19);printf(" R::::R R:::::Ra::::a a:::::ac::::::c ccccccce:::::::e r:::::r \n");delay5;
gotoXY(15,20);printf("RR:::::R R:::::Ra::::a a:::::ac:::::::cccccc:::::ce::::::::e r:::::r \n");delay5;
gotoXY(15,21);printf("R::::::R R:::::Ra:::::aaaa::::::a c:::::::::::::::::c e::::::::eeeeeeee r:::::r \n");delay5;
gotoXY(15,22);printf("R::::::R R:::::R a::::::::::aa:::a cc:::::::::::::::c ee:::::::::::::e r:::::r \n");delay5;
gotoXY(15,23);printf("RRRRRRRR RRRRRRR aaaaaaaaaa aaaa cccccccccccccccc eeeeeeeeeeeeee rrrrrrr \n");delay5;
fflush(stdin);
gotoXY(45,25);system("pause");
Sleep(500);
system("cls");
gotoXY(48,7); printf("*");
while(1==1)
{
gotoXY(50,7); printf(" Play TypeRacer");
gotoXY(50,8); printf(" Learning the art");
gotoXY(50,9); printf(" Game Settings");
gotoXY(50,10); printf(" High-scores");
gotoXY(50,11); printf(" Credits");
gotoXY(50,12); printf(" Exit");
system("pause>nul");
if(GetAsyncKeyState(VK_DOWN) && x != 12) //down button pressed
{
gotoXY(48,x); printf(" ");
x++;
gotoXY(48,x); printf("*");
menu_item++;
continue;
}
if(GetAsyncKeyState(VK_UP) && x != 7) //up button pressed
{
gotoXY(48,x);
printf(" ");
x--;
gotoXY(48,x);
printf("*");
menu_item--;
continue;
}
if(GetAsyncKeyState(VK_RETURN))
{ // Enter key pressed
switch(menu_item)
{
case 0:
{
system("cls");
gotoXY(50,7);
printf(" Play TypeRacer");
Sleep(700);
system("cls");
playerObj.playGame();
break;
}
case 1:
{
gotoXY(35,5);
system("cls");
gotoXY(50,8);
printf(" Learning the art");
Sleep(700);
system("cls");
gotoXY(20,8);printf(" AAA tttt\n");delay5;
gotoXY(20,9);printf(" A:::A ttt:::t\n");delay5;
gotoXY(20,10);printf(" A:::::A t:::::t\n");delay5;
gotoXY(20,11);printf(" A:::::::A t:::::t\n");delay5;
gotoXY(20,12);printf(" A:::::::::A rrrrr rrrrrrrrr ttttttt:::::ttttttt\n");delay5;
gotoXY(20,13);printf(" A:::::A:::::A r::::rrr:::::::::r t:::::::::::::::::t\n");delay5;
gotoXY(20,14);printf(" A:::::A A:::::A r:::::::::::::::::rt:::::::::::::::::t\n");delay5;
gotoXY(20,15);printf(" A:::::A A:::::A rr::::::rrrrr::::::tttttt:::::::tttttt\n");delay5;
gotoXY(20,16);printf(" A:::::A A:::::A r:::::r r:::::r t:::::t\n");delay5;
gotoXY(20,17);printf(" A:::::AAAAAAAAA:::::A r:::::r rrrrrrr t:::::t\n");delay5;
gotoXY(20,18);printf(" A:::::::::::::::::::::A r:::::r t:::::t\n");delay5;
gotoXY(20,19);printf(" A:::::AAAAAAAAAAAAA:::::A r:::::r t:::::t tttttt\n");delay5;
gotoXY(20,20);printf(" A:::::A A:::::A r:::::r t::::::tttt:::::t\n");delay5;
gotoXY(20,21);printf(" A:::::A A:::::A r:::::r tt::::::::::::::t\n");delay5;
gotoXY(20,22);printf(" A:::::A A:::::Ar:::::r tt:::::::::::tt\n");delay5;
gotoXY(20,23);printf("AAAAAAA AAAAAArrrrrrr ttttttttttt\n");delay5;
Sleep(700);
system("cls");
learnTyping();
break;
}
case 2:
{
system("cls");
gotoXY(50,9);
printf(" Game Settings");
Sleep(700);
system("cls");
int difficulty;
char playerName[20];
gotoXY(20,8);printf("MMMMMMMMM MMMMMMMMM DDDDDDDD\n");delay5;
gotoXY(20,9);printf("M::::::::M M::::::::M d::::::d\n");delay5;
gotoXY(20,10);printf("M:::::::::M M:::::::::M d:::::d \n");delay5;
gotoXY(20,11);printf("M::::::::::M M::::::::::M ooooooooooo ddddddddd:::::d eeeeeeeeeeee \n");delay5;
gotoXY(20,12);printf("M:::::::::::M M:::::::::::M oo:::::::::::oo dd::::::::::::::d ee::::::::::::ee \n");delay5;
gotoXY(20,13);printf("M:::::::M::::M M::::M:::::::Mo:::::::::::::::o d::::::::::::::::d e::::::eeeee:::::ee \n");delay5;
gotoXY(20,14);printf("M::::::M M::::M M::::M M::::::Mo:::::ooooo:::::od:::::::ddddd:::::d e::::::e e:::::e \n");delay5;
gotoXY(20,15);printf("M::::::M M::::M::::M M::::::Mo::::o o::::od::::::d d:::::d e:::::::eeeee::::::e \n");delay5;
gotoXY(20,16);printf("M::::::M M:::::::M M::::::Mo::::o o::::od:::::d d:::::d e:::::::::::::::::e \n");delay5;
gotoXY(20,17);printf("M::::::M M:::::M M::::::Mo::::o o::::od:::::d d:::::d e::::::eeeeeeeeeee \n");delay5;
gotoXY(20,18);printf("M::::::M MMMMM M::::::Mo::::o o::::od:::::d d:::::d e:::::::e \n");delay5;
gotoXY(20,19);printf("M::::::M M::::::Mo:::::ooooo:::::od::::::ddddd::::::dde::::::::e \n");delay5;
gotoXY(20,20);printf("M::::::M M::::::Mo:::::::::::::::o d:::::::::::::::::d e::::::::eeeeeeee \n");delay5;
gotoXY(20,21);printf("M::::::M M::::::M oo:::::::::::oo d:::::::::ddd::::d ee:::::::::::::e \n");delay5;
gotoXY(20,22);printf("MMMMMMMM MMMMMMMM ooooooooooo ddddddddd ddddd eeeeeeeeeeeeee \n");delay5;
gotoXY(45,25);printf("Type in a 0 for EASY or 1 for HARD");
gotoXY(45,26);scanf("%d",&difficulty);
fflush(stdin);
gotoXY(45,27);printf("Type in your Name");
gotoXY(45,28);scanf("%s",&playerName);
fflush(stdin);
playerObj.setDifficulty(difficulty,playerName);
system("cls");
break;
}
case 3:
{
system("cls");
gotoXY(50,10);
printf(" High-scores");
Sleep(700);
showHighScores();
break;
}
case 4:
{
system("cls");
gotoXY(50,11);
printf(" Credits");
Sleep(700);
credit();
break;
}
case 5:
{
system("cls");
gotoXY(50,12); printf(" Exit");
Sleep(700);
exit(0);
}
}
}
}
return 0;
}
void learnTyping()
{
Keyboard Learn;
int menu_item=0, x=7;
system("cls");
gotoXY(48,7); printf("*");
while(1==1)
{
gotoXY(50,7); printf(" Lesson 1 \"QWERTY\" Row");
gotoXY(50,8); printf(" Lesson 2 \"ASDFGH\" Row");
gotoXY(50,9); printf(" Lesson 3 \"ZXCVBN\" Row");
gotoXY(50,10); printf(" Lesson 4 \"NUMPAD\"");
gotoXY(50,11); printf(" Return to MAIN MENU");
system("pause>nul"); // the >nul bit causes it the print no message
if(GetAsyncKeyState(VK_DOWN) && x != 11) //down button pressed
{
gotoXY(48,x); printf(" ");
x++;
gotoXY(48,x); printf("*");
menu_item++;
continue;
}
if(GetAsyncKeyState(VK_UP) && x != 7) //up button pressed
{
gotoXY(48,x); printf(" ");
x--;
gotoXY(48,x); printf("*");
menu_item--;
continue;
}
if(GetAsyncKeyState(VK_RETURN))
{
switch(menu_item)
{
case 0:
{
system("cls");
gotoXY(50,7);
printf(" Lesson 1 \"QWERTY\" Row");
Sleep(700);
system("cls");
Learn.qwerty(1);
break;
}
case 1:
{
system("cls");
gotoXY(50,8);
printf(" Lesson 2 \"ASDFGH\" Row");
Sleep(700);
system("cls");
Learn.qwerty(2);
break;
}
case 2:
{
system("cls");
gotoXY(50,9);
printf(" Lesson 3 \"ZXCVBN\" Row");
Sleep(700);
system("cls");
Learn.qwerty(3);
break;
}
case 3:
{
system("cls");
gotoXY(50,10);
printf(" Lesson 4 \"NUMPAD\"");
Sleep(700);
system("cls");
Learn.qwerty(4);
break;
}
case 4:
{
system("cls");
Sleep(700);
main();
}
}
}
}
system("cls");
}
void credit()
{
gotoXY(20,5);printf(",---,---,---,---,---,---,---,---,---,---,---,---,---,-------,\n");delay5;
gotoXY(20,6);printf("| | T | Y | P | E | R | A | C | E | R | | v | 1 |.0.0 |\n");delay5;
gotoXY(20,7);printf("|---'---'---'---'---'---'---'---'---'---'---'---'---'-------|\n");delay5;
gotoXY(20,8);printf("| | S | A | M | A | R | T | H | | 3 | 2 | 4 | 5 | |\n");delay5;
gotoXY(20,9);printf("|-----'---'---'---'---'---'---'---'---'---'---'---'---'-----|\n");delay5;
gotoXY(20,10);printf("| | S | H | I | V | A | M | | 3 | 2 | 5 | 7 | |\n");delay5;
gotoXY(20,11);printf("|------'---'---'---'---'---'---'---'---'---'---'---'--------|\n");delay5;
gotoXY(20,12);printf("| | S | U | K | H | J | O | T | | 3 | 2 | 5 | 2 |\n");delay5;
gotoXY(20,13);printf("|--------'----'---'---'---'---'---'---'---'---'------'------|\n");delay5;
gotoXY(20,14);printf("| JIIT | 128 | | |BATCH | F-8 | SEM 3|\n");delay5;
gotoXY(20,15);printf("'------'------'-----'------------------'------'------'------'\n");delay5;
std::cin.get();
system("cls");
}
void showHighScores()
{
system("cls");
gotoXY(20,8);printf("BBBBBBBBBBBBBBBBB dddddddd\n");delay5;
gotoXY(20,9);printf("B::::::::::::::::B d::::::d\n");delay5;
gotoXY(20,10);printf("B::::::BBBBBB:::::B d::::::d\n");delay5;
gotoXY(20,11);printf("BB:::::B B:::::B d:::::d\n");delay5;
gotoXY(20,12);printf(" B::::B B:::::B ooooooooooo aaaaaaaaaaaaa rrrrr rrrrrrrrr ddddddddd:::::d\n");delay5;
gotoXY(20,13);printf(" B::::B B:::::Boo:::::::::::oo a::::::::::::ar::::rrr:::::::::r dd::::::::::::::d\n");delay5;
gotoXY(20,14);printf(" B::::BBBBBB:::::Bo:::::::::::::::o aaaaaaaaa:::::r:::::::::::::::::r d::::::::::::::::d\n");delay5;
gotoXY(20,15);printf(" B:::::::::::::BB o:::::ooooo:::::o a::::rr::::::rrrrr::::::d:::::::ddddd:::::d\n");delay5;
gotoXY(20,16);printf(" B::::BBBBBB:::::Bo::::o o::::o aaaaaaa:::::ar:::::r r:::::d::::::d d:::::d\n");delay5;
gotoXY(20,17);printf(" B::::B B:::::o::::o o::::o aa::::::::::::ar:::::r rrrrrrd:::::d d:::::d\n");delay5;
gotoXY(20,18);printf(" B::::B B:::::o::::o o::::oa::::aaaa::::::ar:::::r d:::::d d:::::d\n");delay5;
gotoXY(20,19);printf(" B::::B B:::::o::::o o::::a::::a a:::::ar:::::r d:::::d d:::::d\n");delay5;
gotoXY(20,20);printf("BB:::::BBBBBB::::::o:::::ooooo:::::a::::a a:::::ar:::::r d::::::ddddd::::::dd\n");delay5;
gotoXY(20,21);printf("B:::::::::::::::::Bo:::::::::::::::a:::::aaaa::::::ar:::::r d:::::::::::::::::d\n");delay5;
gotoXY(20,22);printf("B::::::::::::::::B oo:::::::::::oo a::::::::::aa:::r:::::r d:::::::::ddd::::d\n");delay5;
gotoXY(20,23);printf("BBBBBBBBBBBBBBBBB ooooooooooo aaaaaaaaaa aaarrrrrrr ddddddddd ddddd\n");delay5;
vector<string>highScores;
string line;
fileObj.open("scores.txt",ios::in);
if(fileObj.fail())
cout<<"failed";
while(fileObj >> line)
{
highScores.push_back(line);
}
sort(highScores.begin(),highScores.end());
for(int ii=0;ii<highScores.size()/2;ii++)
{
gotoXY(40,26+ii);
printf("%s\t\t\t\t\n",highScores[ii].c_str());
}
int gotoPositioner = 0;
for(int ii= highScores.size()/2;ii<highScores.size();ii++)
{
gotoXY(60,26+gotoPositioner);
printf("%s\t\t\t\t\n",highScores[ii].c_str());
gotoPositioner++;
}
cin.get();
fileObj.close();
system("cls");
}