-
Notifications
You must be signed in to change notification settings - Fork 0
/
3_in_1_games.CPP
1042 lines (904 loc) · 22.6 KB
/
3_in_1_games.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
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<graphics.h>
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<iostream.h>
#include<process.h>
#include<ctype.h>
#include<stdlib.h>
#include<string.h>
#define true 1
#define false 0
void drawLine(int n, char symbol); //for casino
void rules();
void country();
void state();
void cricket();
void ticintro();
void *buf; /*for micky mouse*/
void firstleft();
void secondleft();
//for hangman
const int MAXLENGTH=80;
const int MAX_TRIES=6;
const int MAXROW=7;
int letterFill (char, char[], char[]);
void initUnknown (char[], char[]);
void intro();
void disp();
void printmenu();
void intro();
void levelmenu();void easy();
void initial(int x);
void draw(int x, int y, int i);
void userwin(int no);int check(int key);
int load,i,step,level,num[25],win;
char square[10] = {'0','1','2','3','4','5','6','7','8','9'};
void hangman();
void casino();
void micky();
void tictactoe();
void end();
//FOR MOUSE SETTINGS
union REGS in,out;
int callmouse()
{
in.x.ax=1;
int86(51,&in,&out);
return 1;
}
void mouseposi(int &xpos,int &ypos,int &click)
{
in.x.ax=3;
int86(51,&in,&out);
click=out.x.bx;
xpos=out.x.cx;
ypos=out.x.dx;
}
int mousehide()
{
in.x.ax=2;
int86(51,&in,&out);
return 1;
}
void setposi(int &xpos,int &ypos)
{
in.x.ax=4;
in.x.cx=xpos;
in.x.dx=ypos;
int86(51,&in,&out);
}
//-------------------//
void start()
{
int x,y,cl,a,b;
int gd=DETECT,gm;
initgraph(&gd,&gm,"c://tc//bgi");
setcolor(13);
bar3d(100,70,530,150,10,20);
settextstyle(DEFAULT_FONT,HORIZ_DIR,6);
outtextxy(190,90,"GAMES");
bar3d(200,190,400,230,10,20);
setcolor(12);
settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
outtextxy(240,200,"HANGMAN");
setcolor(12);
bar3d(200,250,400,290,10,20);
setcolor(12);
settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
outtextxy(240,260,"GAMBLING");
setcolor(5);
bar3d(200,310,400,350,10,20);
setcolor(12);
settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
outtextxy(220,322,"TIC-TAC-TOE");
setcolor(5);
bar3d(140,380,470,440,10,20);
setcolor(BLUE);
settextstyle(DEFAULT_FONT,HORIZ_DIR,5);
outtextxy(220,400,"EXIT");
a=100;
b=400;
setposi(a,b);
callmouse();
do
{
mouseposi(x,y,cl);
gotoxy(10,9);
if(cl==1 && x>=200 && x<=400 && y>=190 && y<=230)
{
cleardevice();
hangman();
break;
}
else if(cl==1 && x>=200 && x<=400 && y>=250 && y<=290)
{
cleardevice();
casino();
break;
}
else if(cl==1 && x>=200 && x<=400 && y>=310 &&y<=350)
{
cleardevice();
tictactoe();
break;
}
else if(cl==1 && x>=140 && x<=470 && y>=380 &&y<=440)
{
cleardevice();
exit(0);
// end();
break;
}
} while( !kbhit() );
}
void hangman()
{
micky();
cleardevice();
int x,y,cl,a,b;
int gd=DETECT,gm;
initgraph(&gd,&gm,"c://tc//bgi");
setcolor(1);
bar3d(100,70,530,150,10,20);
settextstyle(DEFAULT_FONT,HORIZ_DIR,6);
outtextxy(140,90,"HANGMAN");
bar3d(200,190,400,230,10,20);
setcolor(6);
settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
outtextxy(240,200,"COUNTRY");
setcolor(5);
bar3d(200,250,400,290,10,20);
setcolor(6);
settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
outtextxy(230,260,"CRICKETER");
setcolor(5);
bar3d(200,310,400,350,10,20);
setcolor(6);
settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
outtextxy(200,322,"STATE CAPITAL ");
setcolor(5);
bar3d(140,380,470,440,10,20);
setcolor(RED);
settextstyle(DEFAULT_FONT,HORIZ_DIR,5);
outtextxy(220,400,"EXIT");
a=100;
b=400;
setposi(a,b);
callmouse();
do
{
mouseposi(x,y,cl);
gotoxy(10,9);
if(cl==1 && x>=200 && x<=400 && y>=190 && y<=230)
{
cleardevice();
country();
break;
}
else if(cl==1 && x>=200 && x<=400 && y>=250 && y<=290)
{
cleardevice();
cricket();
break;
}
else if(cl==1 && x>=200 && x<=400 && y>=310 &&y<=350)
{
cleardevice();
state();
break;
}
else if(cl==1 && x>=140 && x<=470 && y>=380 &&y<=440)
{
cleardevice();
end();
break;
}
} while( !kbhit() );
}
void cricket()
{
intro();
char unknown [MAXLENGTH];
char letter;
int num_of_wrong_guesses=0;
char word[MAXLENGTH];
char words[][MAXLENGTH] =
{
"kohli",
"raina",
"dhoni",
"bhuvi",
"chahal",
"jadeja",
"rohit",
"rahane",
"pandya",
"ashwin"
};
//choose and copy a word from array of words randomly
randomize();
int n=random(10);
strcpy(word,words[n]);
// Initialize the secret word with the * character.
initUnknown(word, unknown);
// welcome the user
cout << "\n\nWelcome to hangman...Guess a cricketer's Name";
cout << "\n\nEach letter is represented by a star.";
cout << "\n\nYou have to type only one letter in one try";
cout << "\n\nYou have " << MAX_TRIES << " tries to try and guess the word.";
cout << "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
// Loop until the guesses are used up
while (num_of_wrong_guesses < MAX_TRIES)
{
cout << "\n\n" << unknown;
cout << "\n\nGuess a letter: ";
cin >> letter;
// Fill secret word with letter if the guess is correct,
// otherwise increment the number of wrong guesses.
if (letterFill(letter, word, unknown)==0)
{
cout << endl << "Whoops! That letter isn't in there!" << endl;
num_of_wrong_guesses++;
}
else
{
cout << endl << "You found a letter! Isn't that exciting!" << endl;
}
// Tell user how many guesses is left.
cout << "You have " << MAX_TRIES - num_of_wrong_guesses;
cout << " guesses left." << endl;
// Check if they guessed the word.
if (strcmp(word, unknown) == 0)
{
cout << word << endl;
cout << "Yeah! You got it!";
delay(2000);
break;
}
}
if(num_of_wrong_guesses == MAX_TRIES)
{
cout << "\nSorry, you lose...you've been hanged." << endl;
cout << "The word was : " << word << endl;
delay(2000);
}
}
void state()
{
intro();
char unknown [MAXLENGTH];
char letter;
int num_of_wrong_guesses=0;
char word[MAXLENGTH];
char words[][MAXLENGTH] =
{
"mumbai",
"bengaluru",
"chennai",
"hyderabad",
"vizag",
"patna",
"shimla",
"chandigarh",
"dispur",
"agartala"
};
//choose and copy a word from array of words randomly
randomize();
int n=random(10);
strcpy(word,words[n]);
// Initialize the secret word with the * character.
initUnknown(word, unknown);
// welcome the user
cout << "\n\nWelcome to hangman...Guess a State capital's Name";
cout << "\n\nEach letter is represented by a star.";
cout << "\n\nYou have to type only one letter in one try";
cout << "\n\nYou have " << MAX_TRIES << " tries to try and guess the word.";
cout << "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
// Loop until the guesses are used up
while (num_of_wrong_guesses < MAX_TRIES)
{
cout << "\n\n" << unknown;
cout << "\n\nGuess a letter: ";
cin >> letter;
// Fill secret word with letter if the guess is correct,
// otherwise increment the number of wrong guesses.
if (letterFill(letter, word, unknown)==0)
{
cout << endl << "Whoops! That letter isn't in there!" << endl;
num_of_wrong_guesses++;
}
else
{
cout << endl << "You found a letter! Isn't that exciting!" << endl;
}
// Tell user how many guesses is left.
cout << "You have " << MAX_TRIES - num_of_wrong_guesses;
cout << " guesses left." << endl;
// Check if they guessed the word.
if (strcmp(word, unknown) == 0)
{
cout << word << endl;
cout << "Yeah! You got it!";
delay(2000);
break;
}
}
if(num_of_wrong_guesses == MAX_TRIES)
{
cout << "\nSorry, you lose...you've been hanged." << endl;
cout << "The word was : " << word << endl;
delay(2000);
}
}
void country()
{
intro();
char unknown [MAXLENGTH];
char letter;
int num_of_wrong_guesses=0;
char word[MAXLENGTH];
char words[][MAXLENGTH] =
{
"india",
"pakistan",
"nepal",
"malaysia",
"philippines",
"australia",
"iran",
"ethiopia",
"oman",
"indonesia"
};
//choose and copy a word from array of words randomly
randomize();
int n=random(10);
strcpy(word,words[n]);
// Initialize the secret word with the * character.
initUnknown(word, unknown);
// welcome the user
cout << "\n\nWelcome to hangman...Guess a country Name";
cout << "\n\nEach letter is represented by a star.";
cout << "\n\nYou have to type only one letter in one try";
cout << "\n\nYou have " << MAX_TRIES << " tries to try and guess the word.";
cout << "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
// Loop until the guesses are used up
while (num_of_wrong_guesses < MAX_TRIES)
{
cout << "\n\n" << unknown;
cout << "\n\nGuess a letter: ";
cin >> letter;
// Fill secret word with letter if the guess is correct,
// otherwise increment the number of wrong guesses.
if (letterFill(letter, word, unknown)==0)
{
cout << endl << "Whoops! That letter isn't in there!" << endl;
num_of_wrong_guesses++;
}
else
{
cout << endl << "You found a letter! Isn't that exciting!" << endl;
}
// Tell user how many guesses is left.
cout << "You have " << MAX_TRIES - num_of_wrong_guesses;
cout << " guesses left." << endl;
// Check if they guessed the word.
if (strcmp(word, unknown) == 0)
{
cout << word << endl;
cout << "Yeah! You got it!";
delay(2000);
break;
}
}
if(num_of_wrong_guesses == MAX_TRIES)
{
cout << "\nSorry, you lose...you've been hanged." << endl;
cout << "The word was : " << word << endl;
delay(2000);
}
}
void intro()
{ int i,j;
clrscr();
cleardevice();
setbkcolor(BLACK);
// gotoxy (25,12);
settextstyle(4,0,13);
for(i=0;i<=10;i++)
{
setcolor(i%16);
outtextxy(50,60,"HANGMAN");
settextstyle(1,0,13);
outtextxy(0,110,"OUR GREATEST GLORY IS NOT IN NEVER FALLING... ");
outtextxy(20,130," BUT IN RISING UP EVERY TIME WE FALL");
settextstyle(1,0,13);
outtextxy(20,200,"");
delay(50);
outtextxy(180,200,"A");
delay(50);
outtextxy(220,200,"B");
delay(50);
outtextxy(260,200,"C");
delay(50);
outtextxy(300,200,"D");
delay(50);
outtextxy(180,300,"E");
delay(50);
outtextxy(220,300,"F");
delay(50);
outtextxy(260,300,"G");
delay(50);
outtextxy(300,300,"H");
settextstyle(4,0,13);
delay(50);
}
cleardevice();
}
/* Take a one character guess and the secret word, and fill in the
unfinished guessword. Returns number of characters matched.
Also, returns zero if the character is already guessed. */
int letterFill (char guess, char secretword[], char guessword[])
{
int i;
int matches=0;
for (i = 0; secretword[i]!='\0'; i++)
{
// Did we already match this letter in a previous guess?
if (guess == guessword[i])
return 0;
// Is the guess in the secret word?
if (guess == secretword[i])
{
guessword[i] = guess;
matches++;
}
}
return matches;
}
// Initialize the unknown word
void initUnknown (char word[], char unknown[])
{
int i;
int length = strlen(word);
for (i = 0; i < length; i++)
unknown[i]='*';
unknown[i]='\0';
}
void end()
{
int x,y,cl,a,b;
int gd=DETECT,gm;
initgraph(&gd,&gm,"c://tc//bgi");
setcolor(RED);
bar3d(100,100,530,200,10,20);
setcolor(6);
settextstyle(DEFAULT_FONT,HORIZ_DIR,5);
outtextxy(150,140,"GAME OVER");
delay(1500);
cleardevice();
bar3d(200,230,400,280,10,20);
setcolor(GREEN);
settextstyle(DEFAULT_FONT,HORIZ_DIR,5);
outtextxy(230,240,"HOME");
setcolor(RED);
bar3d(200,320,400,370,10,20);
setcolor(4);
settextstyle(DEFAULT_FONT,HORIZ_DIR,5);
outtextxy(230,330,"EXIT");
a=100;
b=400;
setposi(a,b);
callmouse();
do
{
mouseposi(x,y,cl);
gotoxy(10,9);
if(cl==1 && x>=200 && x<=400 && y>=230 && y<=280)
{
cleardevice();
start();
break;
}
else if(cl==1 && x>=200 && x<=400 && y>=320 && y<=370)
{
exit(0);
break;
}
}while(!kbhit());
}
void casino()
{
micky();
setcolor(12);
settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
outtextxy(600,100," PRESS ENTER TO CONTINUE ");
cleardevice();
char playerName[90];
int amount; // hold player's balance amount
int bettingAmount;
int guess;
int dice; // hold computer generated number
char choice;
srand(time(0)); // "Seed" the random generator
drawLine(60,'=');
cout << "\n\n\n\t\t\t GAMBLING...... \n\n\n\n";
drawLine(60,'=');
outtextxy(0,110,"ITS NOT LIFE IF U KNOW U R GOING TO WIN... ");
// outtextxy(0,100," ITS NOT LIFE IF U KNOW U R GOING TO WIN...");
cout << "\n\n\t Enter Your Name : ";
cin.getline(playerName,50);
cout << "\n\n\t Enter Deposit amount to play game : $";
cin >> amount;
do
{
system("cls");
rules();
cout << "\n\nYour current balance is $ " << amount << "\n";
// Get player's betting amount
do
{
cout <<playerName<<", enter money to bet : $";
cin >> bettingAmount;
if(bettingAmount<=0)
{
cout<<" AMT. SHOULD BE MORE THAN 0 "<<endl;
//goto tryagain;
cout<<" RE ENTER DATA ";
cin>>bettingAmount;
}
if(bettingAmount > amount)
cout << "Your betting amount is more than your current balance\n"
<<"\nRe-enter data\n ";
}while(bettingAmount > amount);
// Get player's numbers
do
{
cout << "Guess your number to bet between 1 to 10 :";
cin >> guess;
if(guess <= 0 || guess > 10)
cout << "Please check the number!! should be between 1 to 10\n"
<<"\nRe-enter data\n ";
}while(guess <= 0 || guess > 10);
dice = rand()%10 + 1; // Will hold the randomly generated integer between 1 and 10
if(dice == guess)
{
cout << "\n\nGood Luck!! You won Rs." << bettingAmount * 10;
amount = amount + bettingAmount * 10;
}
else
{
cout << "Hard Luck this time !! You lost $ "<< bettingAmount <<"\n";
amount = amount - bettingAmount;
}
cout << "\nThe winning number was : " << dice <<"\n";
cout << "\n"<<playerName<<", You have $ " << amount << "\n";
if(amount == 0)
{
cout << "You have no money to play ";
break;
}
cout<<" BUT....";
cout<<"THE BEST THING HUMAN CAN DO IS TRY & TRY AGAIN ";
cout << "\n\n SO ...Do you want to play again (y/n)? ";
cin >> choice;
}while(choice =='Y'|| choice=='y');
cout << "\n\n\n";
drawLine(70,'=');
cout << "\n\n Your balance amount is $ " << amount << "\n\n";
drawLine(70,'=');
end();
}
//void endcs()
//{
// outtextxy(0,110,"the diff. b/w winning and losing is most often not quittng ");
// outtextxy(20,130," BUT IN RISING UP EVERY TIME WE FALL");
//cout<<" the diff. b/w winning and losing is most often not quittng";
void drawLine(int n, char symbol)
{
for(int i=0; i<n; i++)
cout << symbol;
cout << "\n" ;
}
void rules()
{
system("cls");
cout << "\n\n";
drawLine(80,'-');
cout << "\t\tRULES OF THE GAME\n";
drawLine(80,'-');
cout << "\t1. Choose any number between 1 to 10\n";
cout << "\t2. If you win you will get 10 times of money you bet\n";
cout << "\t3. If you bet on wrong number you will lose your betting amount\n\n";
drawLine(80,'-');
}
void tictactoe()
{
micky();
setcolor(12);
ticintro();
settextstyle(DEFAULT_FONT,HORIZ_DIR,7);
outtextxy(600,100," PRESS ENTER TO CONTINUE ");
//delay(500);
cleardevice();
setbkcolor(RED);
//char square[10] = {'o','1','2','3','4','5','6','7','8','9'};
int checkwin();
void board();
int player = 1,i,choice;
char mark;
clrscr();
do
{
board();
player=(player%2)?1:2;
cout << "Player " << player << ", enter a number: ";
cin >> choice;
mark=(player == 1) ? 'X' : 'O';
if (choice == 1 && square[1] == '1')
square[1] = mark;
else if (choice == 2 && square[2] == '2')
square[2] = mark;
else if (choice == 3 && square[3] == '3')
square[3] = mark;
else if (choice == 4 && square[4] == '4')
square[4] = mark;
else if (choice == 5 && square[5] == '5')
square[5] = mark;
else if (choice == 6 && square[6] == '6')
square[6] = mark;
else if (choice == 7 && square[7] == '7')
square[7] = mark;
else if (choice == 8 && square[8] == '8')
square[8] = mark;
else if (choice == 9 && square[9] == '9')
square[9] = mark;
else
{
cout<<"Invalid move ";
player--;
getch();
}
i=checkwin();
player++;
}while(i==-1);
board();
if(i==1)
{
cout<<"==>\aPlayer "<<--player<<" win ";
delay(3000);
} else
{
cout<<"==>\aGame draw";
delay(3000);
}
}
/*********************************************
FUNCTION TO RETURN GAME STATUS
1 FOR GAME IS OVER WITH RESULT
-1 FOR GAME IS IN PROGRESS
O GAME IS OVER AND NO RESULT
**********************************************/
int checkwin()
{
if (square[1] == square[2] && square[2] == square[3])
return 1;
else if (square[4] == square[5] && square[5] == square[6])
return 1;
else if (square[7] == square[8] && square[8] == square[9])
return 1;
else if (square[1] == square[4] && square[4] == square[7])
return 1;
else if (square[2] == square[5] && square[5] == square[8])
return 1;
else if (square[3] == square[6] && square[6] == square[9])
return 1;
else if (square[1] == square[5] && square[5] == square[9])
return 1;
else if (square[3] == square[5] && square[5] == square[7])
return 1;
else if (square[1] != '1' && square[2] != '2' && square[3] != '3' &&
square[4] != '4' && square[5] != '5' && square[6] != '6' &&
square[7] != '7' && square[8] != '8' && square[9] != '9')
return 0;
else
return -1;
}
void ticintro()
{
setcolor(RED);
bar3d(100,100,530,200,10,20);
setcolor(6);
settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
outtextxy(120,140,"MAKE YOUR MOVES CAREFULLY");
delay(3000);
cleardevice();
}
/*******************************************************************
FUNCTION TO DRAW BOARD OF TIC TAC TOE WITH PLAYERS MARK
********************************************************************/
void board()
{
clrscr();
cout << "\n\n\tTic Tac Toe\n\n";
cout << "Player 1 (X) - Player 2 (O)" << endl << endl;
cout << endl;
cout << " | | " << endl;
cout << " " << square[1] << " | " << square[2] << " | " << square[3] << endl;
cout << "_____|_____|_____" << endl;
cout << " | | " << endl;
cout << " " << square[4] << " | " << square[5] << " | " << square[6] << endl;
cout << "_____|_____|_____" << endl;
cout << " | | " << endl;
cout << " " << square[7] << " | " << square[8] << " | " << square[9] << endl;
cout << " | | " << endl << endl;
}
void main()
{
start();
cleardevice();
end();
getch();
closegraph();
restorecrtmode();
}
void micky()
{
int h=0;
int gd=DETECT,gm,n,m,area;
//initgraph( &gd,&gm,"c://tc//bgi");//put your directory contains egavga.bgi
initgraph(&gd,&gm,"c://tc//bgi");
settextstyle(DEFAULT_FONT,HORIZ_DIR,4);
outtextxy(320,300,"WELCOME");
settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
outtextxy(310,380,"CLICK ENTER TO PLAY");
rectangle(0,0,getmaxx(),getmaxy());
arc(240,120,40,140,70);
ellipse(165,80,10,280,20,20);
ellipse(315,80,-100,170,20,20);
arc(235,120,163,215,70);
arc(245,120,-35,17,70);
ellipse(193,178,85,280,40,20);
ellipse(283,178,-100,95,40,20);
ellipse(238,199,180,0,39,50);
ellipse(213,123,44,240,33,40);
ellipse(262,123,-60,135,33,40);
ellipse(210,123,0,360,13,20);//left eye
ellipse(265,123,0,360,13,20);//right eye
ellipse(210,133,0,360,10,10);//left eye ball
ellipse(265,133,0,360,10,10);//right eye ball
ellipse(210,133,0,360,3,3);//left eye ball
ellipse(265,133,0,360,3,3);//right eye ball
ellipse(238,160,0,360,10,13);//nose
arc(240,125,228,312,68);//mouth
arc(240,120,230,310,72);//mouth
setfillstyle(1,4);
floodfill(238,160,15);//nose
setfillstyle(1,15);
floodfill(210,113,15);
floodfill(265,113,15);
setfillstyle(1,9);
floodfill(210,100,15);
setfillstyle(1,1);
floodfill(315,80,15);
moveto(203,220);
lineto(203,260);
lineto(183,260);
lineto(183,350);
lineto(293,350);
lineto(293,260);
lineto(273,260);
lineto(273,220);
moveto(183,350);
lineto(173,460);
lineto(213,460);
lineto(238,400);
lineto(263,460);
lineto(303,460);
lineto(293,350);
moveto(173,460);
lineto(143,478);
lineto(213,478);
lineto(213,460);
moveto(263,460);
lineto(263,478);
lineto(333,478);
lineto(303,460);
line(238,400,238,350);
//right hand
moveto(183,260);
lineto(113,310);
lineto(183,375);
moveto(183,280);
lineto(137,310);
lineto(181,353);
setfillstyle(2,13);
floodfill(190,300,15);
setfillstyle(1,5);
floodfill(223,400,15);
setfillstyle(1,5);
floodfill(253,400,15);
setfillstyle(1,6);
floodfill(173,470,15);
floodfill(303,470,15);
//fingers
secondleft();
ellipse(413.5,228,0,180,3.5,3.5);
line(420,240,433,240);
line(423,247,440,247);
line(413,240,410,228);
line(417,228,420,240);
ellipse(433,243.5,-90,90,3.5,3.5);
line(423,254,440,254);
ellipse(440,250.5,-90,90,3.5,3.5);
ellipse(430,257,-90,90,3,3);
line(413,260,430,260);
area=imagesize(409,224,444,261);
buf=malloc(area);
getimage(409,224,444,261,buf);
while(!kbhit())
{
if(h==0)
{
setfillstyle(1,15);
setcolor(15);
ellipse(210,133,0,360,10,10);//left eye ball
ellipse(265,133,0,360,10,10);//right eye ball
setcolor(0);
ellipse(210,133,0,360,3,3);//left eye ball
ellipse(265,133,0,360,3,3);//right eye ball
floodfill(210,133,15);
floodfill(265,133,15);
setcolor(0);
putimage(391,209,buf,1);
firstleft();
setcolor(15);
secondleft();
putimage(409,224,buf,0);
h=1;
}
else