[ create a new paste ] login | about

Link: http://codepad.org/hvB58K5J    [ raw code | output | fork ]

C++, pasted on Jun 6:
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
/*
Author: <Removed>
Created in Spring 2004

 This is the classic game of Snake. The object of the game is to eat the food
that appears on the board, which increases the length of your snake by a factor
of one. Your score is the amount of additional lengths you aquire before losing.
You lose by either running into yourself or into a barrier or wall.

 I created this game for my end-of-the-year project in Computer Science II for my
senior year of high school. I used Borland C++ 5.02 to create and compile this
program.

 Thank you to my Computer Science I and II teacher, <Removed>. She has taught me
me everything I know, supports me 100%, and continues to challenge me.

 Also Thanks to Mohammed Ali Akbani for creating the In9.h header file and releasing
it as freeware. This header file was "key" to my program.
*/

#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
#include <dos.h>
#include <stdio.h>
#include <fstream.h>
#include <windows.h>

#include "dosgraphics.h"
#include "int9.h"

int num;

void main()

{		//open main
	int choice=0,player,menu();
   void intro(),game(int),instructions();

   opengraph();		//activates BGI graphics

   intro();		//calls intro function
   getch();
   cleardevice();

   while(choice!=3)
   {		//open while
   cleardevice();

   choice=menu();		//the option selected from the menu

   cleardevice();

   if(choice==1)
   	player=1;
   if(choice==4)
   	player=2;

   if (choice==1||choice==4)
   	game(player);		//calls the game function
   if (choice==2)
   	instructions();		//calls the instructions function
   if (choice==3)
   	NULL;		//closes program
   }		//close while

   closegraph();		//deactivates BGI graphics
}		//close main

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~INTRO FUNCTION~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

void intro()

{		//open intro function
   int speed=0,x=0,y=30,a=0;
   bool plus=true;

	setbkcolor(DARKGRAY);

   while(!kbhit())
   {		//open while
      cleardevice();
      if(a==0)
		{		//open if
      	x++;
         y--;
      }		//close if
      if(a==1)
      {		//open if
      	x--;
         y++;
      }		//close if

      settextstyle(TRIPLEX_FONT,HORIZ_DIR,14);

   	settextjustify(CENTER_TEXT,CENTER_TEXT);
   	setcolor(WHITE);
		outtextxy(160,(speed+240),"S");
      outtextxy(240,(-speed+240),"N");
      outtextxy(320,(speed+240),"A");
      outtextxy(400,(-speed+240),"K");
      outtextxy(480,(speed+240),"E");

      if(speed==-10)
      	plus=true;
      if(speed==10)
      	plus=false;

      if(plus)
      	speed++;
      if(!plus)
      	speed--;

      settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
      outtextxy(320,400,"Press any key to continue.");

      setcolor(GREEN);
      circle(50,50,x);
      circle(590,430,x);
      circle(50,430,y);
      circle(590,50,y);

      circle(50,50,y);
      circle(590,430,y);
      circle(50,430,x);
      circle(590,50,x);

      if(x==30)
      	a=1;
      if(x==1)
         a=0;

      delay(25);
   }		//close while
   settextstyle(TRIPLEX_FONT,HORIZ_DIR,14);


   for(num=240;num>50;num=num-2)
   {		//open for
   	outtextxy(160,num,"S");
   	outtextxy(240,num,"N");
   	outtextxy(320,num,"A");
   	outtextxy(400,num,"K");
   	outtextxy(480,num,"E");

      delay(25);
   	cleardevice();
   }		//close for

}		//close intro function

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~GAME FUNCTION~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

void game(int player)

{		//open game function
   int hs,score=0;
   char difficulty(),diff,hold[5],*hsname1="",*hsname2="",*name[2]={"",""};
   ifstream infile;
   void movement(int&,char),newhs(int),movement2(int&,char);

   setbkcolor(DARKGRAY);

   diff=difficulty();		//gets the difficulty setting

   cleardevice();

   setcolor(RED);
   settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);
   settextjustify(CENTER_TEXT,CENTER_TEXT);
   outtextxy(320,50,"Controls");

   if(player==1)
   {		//open if
      outtextxy(320,150,"Up - Up Arrow");
      outtextxy(320,170,"Down - Down Arrow");
      outtextxy(320,190,"Left - Left Arrow");
      outtextxy(320,210,"Right - Right Arrow");
   }		//close if
   if(player==2)
   {		//open if
      setcolor(YELLOW);
      outtextxy(320,150,"Player 1 (YELLOW)");
      setcolor(RED);
      outtextxy(320,200,"Up - Up Arrow");
      outtextxy(320,220,"Down - Down Arrow");
      outtextxy(320,240,"Left - Left Arrow");
      outtextxy(320,260,"Right - Right Arrow");
      setcolor(BLUE);
      outtextxy(320,340,"Player 2 (BLUE)");
      setcolor(RED);
      outtextxy(320,390,"Up - W");
      outtextxy(320,410,"Down - S");
      outtextxy(320,430,"Left - A");
      outtextxy(320,450,"Right - D");
   }		//close if

   getch();
   cleardevice();

   setcolor(WHITE);
   line(54,54,586,54);		//boundaries
   line(586,54,586,426);
   line(586,426,54,426);
   line(54,426,54,54);

   settextjustify(LEFT_TEXT,CENTER_TEXT);
   settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
   outtextxy(400,435,"Press 'Q' to quit");

   settextjustify(RIGHT_TEXT,CENTER_TEXT);
   outtextxy(240,435,"Press 'P' to pause");

   settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
   settextjustify(CENTER_TEXT,CENTER_TEXT);
   outtextxy(100,45,"Score:");
   settextjustify(LEFT_TEXT,CENTER_TEXT);
   outtextxy(140,45,"0");

   if(player==1)
   {		//open if
   infile.open("hs1.dat");
   if(infile.fail())		//if hs.dat doesn't exist, sets the high score to zero
   	hs=0;
   else
   	infile>>hs>>name[0];
   }		//close if
   if(player==2)
   {		//open if
   infile.open("hs2.dat");
   if(infile.fail())		//if hs2.dat doesn't exist, sets the high score to zero
   	hs=0;
   else
   	infile>>hs;
   }		//close if

   sprintf(hold,"%d",hs);
   outtextxy(350,45,"High Score:");
   outtextxy(460,45,hold);
   hold=="";
   outtextxy(500,45,"-");

   settextjustify(CENTER_TEXT, CENTER_TEXT);
   setcolor(RED);
   outtextxy(320,240,"Press any key to begin.");
   getch();

   setcolor(DARKGRAY);
   outtextxy(320,240,"Press any key to begin.");

   settextjustify(LEFT_TEXT,CENTER_TEXT);

   if(player==1)
   {		//open if
      outtextxy(520,45,name[0]);
   	movement(score,diff);		//calls the movement function (1 Player)
   }		//close if
   if(player==2)
   {		//open if
      infile>>name[1];
      outtextxy(520,45,name[1]);
      infile>>name[0];
      outtextxy(520,25,name[0]);
   	movement2(score,diff);		//calls the movement2 function (2 Player)
   }		//close if

   settextstyle(GOTHIC_FONT,HORIZ_DIR,5);
   settextjustify(CENTER_TEXT,CENTER_TEXT);
   setcolor(RED);

   outtextxy(320,260,"GAME OVER");
   delay(1000);
   getch();

   if(score>hs)		//if current score is greater than current high score
   {		//open if
      cleardevice();
   	newhs(score);
      cleardevice();
      setbkcolor(BLACK);
      ofstream outfile;
      if(player==1)
      {		//open if
      	cout <<"First Name or Initials: ";
         cin >>hsname1;
         while(hsname1=="")
         	cin >>hsname1;

         outfile.open("hs1.dat");
         outfile <<score<<" "<<hsname1;
      }		//close if
      if(player==2)
      {		//open if
         outfile.open("hs2.dat");
         outfile <<score<<" ";
      	cout <<"Player 1's First Name or Initials: ";
         	cin >>hsname1;
         outfile <<hsname1<<" ";
         cout <<"Player 2's First Name or Initials: ";
         	cin >>hsname2;
         outfile <<hsname2;
      }		//close if
   }		//close if
}     //close game function

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~DIFFICULTY FUNCTION~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

char difficulty()

{		//open difficulty function
   char select=' ';

	settextstyle(TRIPLEX_FONT,HORIZ_DIR,5);
   settextjustify(CENTER_TEXT,CENTER_TEXT);
   setcolor(RED);

   outtextxy(320,150,"Select your difficulty");
   settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);
   outtextxy(320,250,"1) Easy (Normal Speed, Normal Length Increments");
   outtextxy(320,300,"2) Normal (Fast Speed, Normal Length Increments");
   outtextxy(320,350,"3) Hard (Fast Speed, Fast Length Increments");

   while(select!='3'&&select!='2'&&select!='1')		//select must be 1, 2, or 3
   	select=getch();

   cleardevice();

   if(select=='1')
   	outtextxy(320,240,"Easy difficulty selected.");
   if(select=='2')
   	outtextxy(320,240,"Normal difficulty selected.");
   if(select=='3')
   	outtextxy(320,240,"Hard difficulty selected.");

   delay(1500);

   return select;
}		//close difficulty function

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~MOVEMENT FUNCTION~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

void movement(int& score,char diff)

{		//open movement function
	int x=520,y=240,len=5,cir[199][2],foodx=300,foody=300,speed=100,inc=10;
   char dir=KEY_LEFT,olddir,hold[5]="0";
   bool hit=false;
   randomize();

   if(diff=='1')
   {		//open if
   	speed=100;
      inc=10;
   }		//close if
   if(diff=='2')
   {		//open if
   	speed=65;
      inc=15;
   }		//close if
   if(diff=='3')
	{		//open if
   	speed=65;
      inc=20;
   }		//close if

   for(num=0;num<len;num++)
   {		//open for
   	cir[num][0]=x;
      cir[num][1]=y;

      x=x+10;
   }		//close for

   setcolor(GREEN);
   setfillstyle(1,GREEN);

	for(num=0;num<len;num++)
   {		//open for
   	circle(cir[num][0],cir[num][1],5);
      floodfill(cir[num][0],cir[num][1],GREEN);
   }		//close for

   setcolor(RED);
   circle(foodx,foody,3);		//draws the initial food
   setfillstyle(1,RED);
   floodfill(foodx,foody,RED);

   while(dir!='q'&&dir!='Q')
   {		//open while
   while(!kbhit()&&!hit)
   {		//open while
      if(cir[0][0]==foodx&&cir[0][1]==foody)		//if the snake runs over the food
      {		//open if
         if(diff=='3')
         	len=len+4;		//increases length
         else
         	len=len+2;

         setcolor(DARKGRAY);
         sprintf(hold, "%d",score);
         outtextxy(140,45,hold);
         hold=="";

         score=score+inc;		//increases score

         setcolor(WHITE);
         sprintf(hold, "%d",score);
         outtextxy(140,45,hold);

         foodx=(random(53)+1)*10+50;		//generates new food location
         foody=(random(37)+1)*10+50;

         for(num=0;num<len;num++)		//incase the food generates on top of the snake
         	if(foodx==cir[num][0]&&foody==cir[num][1])
            {		//open if
            	foodx=(random(53)+1)*10+50;
         		foody=(random(37)+1)*10+50;

               num=0;
            }		//close if

         setcolor(RED);
         circle(foodx,foody,3);		//draws food
         setfillstyle(1,RED);
         floodfill(foodx,foody,RED);
      }		//close if

      setcolor(DARKGRAY);
      setfillstyle(1,DARKGRAY);

      circle(cir[(len-1)][0],cir[(len-1)][1],5);
      floodfill(cir[(len-1)][0],cir[(len-1)][1],DARKGRAY);

      for(num=(len-1);num>0;num--)
      {		//open for
      	cir[num][0]=cir[(num-1)][0];
         cir[num][1]=cir[(num-1)][1];
      }		//close for

      if(dir==KEY_UP)
      	cir[0][1]=cir[0][1]-10;
      if(dir==KEY_DOWN)
      	cir[0][1]=cir[0][1]+10;
      if(dir==KEY_LEFT)
      	cir[0][0]=cir[0][0]-10;
      if(dir==KEY_RIGHT)
      	cir[0][0]=cir[0][0]+10;

      setcolor(GREEN);
   	setfillstyle(1,GREEN);

      circle(cir[0][0],cir[0][1],5);		//draws the head
      floodfill(cir[0][0],cir[0][1],GREEN);		//fills the head

      setcolor(YELLOW);
      setfillstyle(1,YELLOW);

      if(dir==KEY_UP||dir==KEY_DOWN)
      {		//open if
      	circle((cir[0][0]+1),(cir[0][1]-1),1);		//draws the eye
         floodfill((cir[0][0]+1),(cir[0][1]-1),YELLOW);		//fills the eye
      }		//close if
      if(dir==KEY_LEFT||dir==KEY_RIGHT)
      {		//open if
      	circle((cir[0][0]-1),(cir[0][1]-1),1);
         floodfill((cir[0][0]-1),(cir[0][1]-1),YELLOW);
      }		//close if

      if(cir[0][0]<55||cir[0][0]>585)		//If the snake hits horizontal wall
      	hit=true;
      if(cir[0][1]<55||cir[0][1]>425)     //If the snake hits vertical wall
      	hit=true;

      if(hit)
      {		//open if
         setcolor(RED);
         settextstyle(COMPLEX_FONT,HORIZ_DIR,3);
   		settextjustify(CENTER_TEXT,CENTER_TEXT);
      	outtextxy(320,220,"You ran into the wall!");
      }		//close if

      for(num=1;num<len;num++)		//checks to see if the head runs into the body
      {		//open for
      	if(cir[0][0]==cir[num][0]&&cir[0][1]==cir[num][1])
         {		//open if
         	hit=true;
            num=len;

            setcolor(RED);
            settextstyle(COMPLEX_FONT,HORIZ_DIR,3);
   			settextjustify(CENTER_TEXT,CENTER_TEXT);
            outtextxy(320,220,"You ran into yourself!");
         }		//close if
      }		//close for
      delay(speed);
   }		//close while
   if(dir==KEY_LEFT)		//holds the previous direction of the snake
   	olddir='a';
   if(dir==KEY_RIGHT)
   	olddir='d';
   if(dir==KEY_UP)
   	olddir='w';
   if(dir==KEY_DOWN)
   	olddir='s';

   if(!hit)
   	dir=getch();		//holds the new direction of the snake

   if(dir=='p')		//to pause the game
   {		//open if
      setcolor(WHITE);
   	outtextxy(320,240,"Paused");

      dir=NULL;

      while(dir!='p')
      	dir=getch();

      setcolor(DARKGRAY);
      outtextxy(320,240,"Paused");
   }		//close if

   if(olddir=='a'&&dir==KEY_RIGHT)		//if the previous direction and the new
   	dir=olddir;                      //direction are opposites, set the new
   if(olddir=='d'&&dir==KEY_LEFT)      //direction equal to the previous direction.
   	dir=olddir;
   if(olddir=='w'&&dir==KEY_DOWN)
   	dir=olddir;
   if(olddir=='s'&&dir==KEY_UP)
   	dir=olddir;

   if(dir=='a')		//reinstates the new direction of the snake
   	dir=KEY_LEFT;
   if(dir=='d')
   	dir=KEY_RIGHT;
   if(dir=='w')
   	dir=KEY_UP;
   if(dir=='s')
   	dir=KEY_DOWN;

   if(hit)
   	dir='q';
   }		//close while
}		//close movement function

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~MOVEMENT2 FUNCTION~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

void movement2(int& score,char diff)

{		//open movement function
	int x=520,y=240,len=5,cir[199][2],foodx=300,foody=300,speed=100,inc=10;
   int x2=120,y2=240,len2=5,cir2[199][2],foodx2=500,foody2=300;
   char dir=KEY_LEFT,olddir,hold[5]="0",dirhold='a';
   char dir2=KEY_D,olddir2;
   bool hit=false;
   randomize();

   if(diff=='1')
   {		//open if
   	speed=100;
      inc=10;
   }		//close if
   if(diff=='2')
   {		//open if
   	speed=65;
      inc=15;
   }		//close if
   if(diff=='3')
	{		//open if
   	speed=65;
      inc=20;
   }		//close if

   for(num=0;num<len;num++)
   {		//open for
   	cir[num][0]=x;
      cir[num][1]=y;

      x=x+10;
   }		//close for
   for(num=0;num<len2;num++)
   {		//open for
      cir2[num][0]=x2;
      cir2[num][1]=y2;

      x2=x2-10;
   }		//close for

   setcolor(GREEN);
   setfillstyle(1,GREEN);

	for(num=0;num<len;num++)
   {		//open for
   	circle(cir[num][0],cir[num][1],5);
      floodfill(cir[num][0],cir[num][1],GREEN);
   }		//close for
   for(num=0;num<len2;num++)
   {		//open for
      circle(cir2[num][0],cir2[num][1],5);
      floodfill(cir2[num][0],cir2[num][1],GREEN);
   }		//close for

   setcolor(RED);
   circle(foodx,foody,3);		//draws the initial food
   circle(foodx2,foody2,3);
   setfillstyle(1,RED);
   floodfill(foodx,foody,RED);
   floodfill(foodx2,foody2,RED);

   while(dirhold!='q'&&dirhold!='Q')
   {		//open while
   while(!kbhit()&&!hit)
   {		//open while
      if(cir[0][0]==foodx&&cir[0][1]==foody)		//if the snake runs over the food
      {		//open if
         if(diff=='3')
         	len=len+4;		//increases length
         else
         	len=len+2;

         setcolor(DARKGRAY);
         sprintf(hold, "%d",score);
         outtextxy(140,45,hold);
         hold=="";

         score=score+inc;		//increases score

         setcolor(WHITE);
         sprintf(hold, "%d",score);
         outtextxy(140,45,hold);

         foodx=(random(53)+1)*10+50;		//generates new food location
         foody=(random(37)+1)*10+50;

         for(num=0;num<len;num++)		//incase the food generates on top of the snake
         	if(foodx==cir[num][0]&&foody==cir[num][1])
            {		//open if
            	foodx=(random(53)+1)*10+50;
         		foody=(random(37)+1)*10+50;

               num=0;
            }		//close if
         for(num=0;num<len2;num++)		//incase the food generates on top of the snake2
         	if(foodx==cir2[num][0]&&foody==cir2[num][1])
            {		//open if
            	foodx=(random(53)+1)*10+50;
         		foody=(random(37)+1)*10+50;

               num=0;
            }		//close if

         setcolor(RED);
         circle(foodx,foody,3);		//draws food
         setfillstyle(1,RED);
         floodfill(foodx,foody,RED);
      }		//close if

      if(cir[0][0]==foodx2&&cir[0][1]==foody2)		//if the snake runs over the food
      {		//open if
         if(diff=='3')
         	len=len+4;		//increases length
         else
         	len=len+2;

         setcolor(DARKGRAY);
         sprintf(hold, "%d",score);
         outtextxy(140,45,hold);
         hold=="";

         score=score+inc;		//increases score

         setcolor(WHITE);
         sprintf(hold, "%d",score);
         outtextxy(140,45,hold);

         foodx2=(random(53)+1)*10+50;		//generates new food location
         foody2=(random(37)+1)*10+50;

         for(num=0;num<len;num++)		//incase the food generates on top of the snake
         	if(foodx2==cir[num][0]&&foody2==cir[num][1])
            {		//open if
            	foodx2=(random(53)+1)*10+50;
         		foody2=(random(37)+1)*10+50;

               num=0;
            }		//close if
         for(num=0;num<len2;num++)		//incase the food generates on top of the snake
         	if(foodx2==cir2[num][0]&&foody2==cir2[num][1])
            {		//open if
            	foodx2=(random(53)+1)*10+50;
         		foody2=(random(37)+1)*10+50;

               num=0;
            }		//close if

         setcolor(RED);
         circle(foodx2,foody2,3);		//draws food
         setfillstyle(1,RED);
         floodfill(foodx2,foody2,RED);
      }		//close if

      if(cir2[0][0]==foodx&&cir2[0][1]==foody)		//if the snake runs over the food
      {		//open if
         if(diff=='3')
         	len2=len2+4;		//increases length
         else
         	len2=len2+2;

         setcolor(DARKGRAY);
         sprintf(hold, "%d",score);
         outtextxy(140,45,hold);
         hold=="";

         score=score+inc;		//increases score

         setcolor(WHITE);
         sprintf(hold, "%d",score);
         outtextxy(140,45,hold);

         foodx=(random(53)+1)*10+50;		//generates new food location
         foody=(random(37)+1)*10+50;

         for(num=0;num<len2;num++)		//incase the food generates on top of the snake
         	if(foodx==cir2[num][0]&&foody==cir2[num][1])
            {		//open if
            	foodx=(random(53)+1)*10+50;
         		foody=(random(37)+1)*10+50;

               num=0;
            }		//close if

         setcolor(RED);
         circle(foodx,foody,3);		//draws food
         setfillstyle(1,RED);
         floodfill(foodx,foody,RED);
      }		//close if

      if(cir2[0][0]==foodx2&&cir2[0][1]==foody2)		//if the snake runs over the food
      {		//open if
         if(diff=='3')
         	len2=len2+4;		//increases length
         else
         	len2=len2+2;

         setcolor(DARKGRAY);
         sprintf(hold, "%d",score);
         outtextxy(140,45,hold);
         hold=="";

         score=score+inc;		//increases score

         setcolor(WHITE);
         sprintf(hold, "%d",score);
         outtextxy(140,45,hold);

         foodx2=(random(53)+1)*10+50;		//generates new food location
         foody2=(random(37)+1)*10+50;

         for(num=0;num<len2;num++)		//incase the food generates on top of the snake
         	if(foodx2==cir2[num][0]&&foody2==cir2[num][1])
            {		//open if
            	foodx2=(random(53)+1)*10+50;
         		foody2=(random(37)+1)*10+50;

               num=0;
            }		//close if

         setcolor(RED);
         circle(foodx2,foody2,3);		//draws food
         setfillstyle(1,RED);
         floodfill(foodx2,foody2,RED);
      }		//close if

      setcolor(DARKGRAY);
      setfillstyle(1,DARKGRAY);

      circle(cir[(len-1)][0],cir[(len-1)][1],5);
      floodfill(cir[(len-1)][0],cir[(len-1)][1],DARKGRAY);

      circle(cir2[(len2-1)][0],cir2[(len2-1)][1],5);
      floodfill(cir2[(len2-1)][0],cir2[(len2-1)][1],DARKGRAY);

      for(num=(len-1);num>0;num--)
      {		//open for
      	cir[num][0]=cir[(num-1)][0];
         cir[num][1]=cir[(num-1)][1];
      }		//close for
      for(num=(len2-1);num>0;num--)
      {		//open for
         cir2[num][0]=cir2[(num-1)][0];
         cir2[num][1]=cir2[(num-1)][1];
      }		//close for

      if(dir==KEY_UP)
      	cir[0][1]=cir[0][1]-10;
      if(dir==KEY_DOWN)
      	cir[0][1]=cir[0][1]+10;
      if(dir==KEY_LEFT)
      	cir[0][0]=cir[0][0]-10;
      if(dir==KEY_RIGHT)
      	cir[0][0]=cir[0][0]+10;

      if(dir2==KEY_W)
      	cir2[0][1]=cir2[0][1]-10;
      if(dir2==KEY_S)
      	cir2[0][1]=cir2[0][1]+10;
      if(dir2==KEY_A)
      	cir2[0][0]=cir2[0][0]-10;
      if(dir2==KEY_D)
      	cir2[0][0]=cir2[0][0]+10;

      setcolor(GREEN);
   	setfillstyle(1,GREEN);

      circle(cir[0][0],cir[0][1],5);		//draws the head
      floodfill(cir[0][0],cir[0][1],GREEN);		//fills the head

      circle(cir2[0][0],cir2[0][1],5);		//draws the head
      floodfill(cir2[0][0],cir2[0][1],GREEN);		//fills the head

      setcolor(YELLOW);
      setfillstyle(1,YELLOW);

      if(dir==KEY_UP||dir==KEY_DOWN)
      {		//open if
      	circle((cir[0][0]+1),(cir[0][1]-1),1);		//draws the dot
         floodfill((cir[0][0]+1),(cir[0][1]-1),YELLOW);		//fills the dot
      }		//close if
      if(dir==KEY_LEFT||dir==KEY_RIGHT)
      {		//open if
      	circle((cir[0][0]-1),(cir[0][1]-1),1);
         floodfill((cir[0][0]-1),(cir[0][1]-1),YELLOW);
      }		//close if

      setcolor(BLUE);
      setfillstyle(1,BLUE);

      if(dir2==KEY_W||dir2==KEY_S)
      {		//open if
      	circle((cir2[0][0]+1),(cir2[0][1]-1),1);		//draws the dot
         floodfill((cir2[0][0]+1),(cir2[0][1]-1),BLUE);		//fills the dot
      }		//close if
      if(dir2==KEY_A||dir2==KEY_D)
      {		//open if
      	circle((cir2[0][0]-1),(cir2[0][1]-1),1);
         floodfill((cir2[0][0]-1),(cir2[0][1]-1),BLUE);
      }		//close if

      if(cir[0][0]<55||cir[0][0]>585)		//If the snake hits horizontal wall
      	hit=true;
      if(cir[0][1]<55||cir[0][1]>425)     //If the snake hits vertical wall
      	hit=true;

      if(cir2[0][0]<55||cir2[0][0]>585)		//If the snake hits horizontal wall
      	hit=true;
      if(cir2[0][1]<55||cir2[0][1]>425)     //If the snake hits vertical wall
      	hit=true;

      if(hit)
      {		//open if
         setcolor(RED);
         settextstyle(COMPLEX_FONT,HORIZ_DIR,3);
   		settextjustify(CENTER_TEXT,CENTER_TEXT);
         if((cir[0][0]<55||cir[0][0]>585)||(cir[0][1]<55||cir[0][1]>425))
      		outtextxy(320,220,"Player 1 ran into the wall!");
         if((cir2[0][0]<55||cir2[0][0]>585)||(cir2[0][1]<55||cir2[0][1]>425))
      		outtextxy(320,220,"Player 2 ran into the wall!");
      }		//close if

      if(cir[0][0]==cir2[0][0]&&cir[0][1]==cir2[0][1])
      {		//open if
      	if((dir==KEY_LEFT&&dir2==KEY_D)||(dir==KEY_RIGHT&&dir2==KEY_A))
         {		//open if
         	hit=true;

            setcolor(RED);
            settextstyle(COMPLEX_FONT,HORIZ_DIR,3);
   			settextjustify(CENTER_TEXT,CENTER_TEXT);
            outtextxy(320,220,"Head on collision!");
         }		//close if
         else if((dir==KEY_UP&&dir2==KEY_S)||(dir==KEY_DOWN&&dir2==KEY_W))
         {		//open else if
         	hit=true;

            setcolor(RED);
            settextstyle(COMPLEX_FONT,HORIZ_DIR,3);
   			settextjustify(CENTER_TEXT,CENTER_TEXT);
            outtextxy(320,220,"Head on collision!");
         }		//close else if
         else
         {		//open else
         	hit=true;

            setcolor(RED);
            settextstyle(COMPLEX_FONT,HORIZ_DIR,3);
   			settextjustify(CENTER_TEXT,CENTER_TEXT);
            outtextxy(320,220,"Massive snake accident!");
         }		//close else
      }		//close if

      if(!hit)
      for(num=1;num<len;num++)		//checks to see if the head runs into the body
      {		//open for
      	if(cir[0][0]==cir[num][0]&&cir[0][1]==cir[num][1])
         {		//open if
         	hit=true;
            num=len;

            setcolor(RED);
            settextstyle(COMPLEX_FONT,HORIZ_DIR,3);
   			settextjustify(CENTER_TEXT,CENTER_TEXT);
            outtextxy(320,220,"Player 1 ran into himself!");
         }		//close if
         if(cir2[0][0]==cir[num][0]&&cir2[0][1]==cir[num][1])
         {		//open if
         	hit=true;
            num=len;

            setcolor(RED);
            settextstyle(COMPLEX_FONT,HORIZ_DIR,3);
   			settextjustify(CENTER_TEXT,CENTER_TEXT);
            outtextxy(320,220,"Player 2 ran into Player 1!");
         }		//close if
      }		//close for

      if(!hit)
      for(num=1;num<len2;num++)		//checks to see if the head runs into the body
      {		//open for
      	if(cir2[0][0]==cir2[num][0]&&cir2[0][1]==cir2[num][1])
         {		//open if
         	hit=true;
            num=len2;

            setcolor(RED);
            settextstyle(COMPLEX_FONT,HORIZ_DIR,3);
   			settextjustify(CENTER_TEXT,CENTER_TEXT);
            outtextxy(320,220,"Player 2 ran into himself!");
         }		//close if
         if(cir[0][0]==cir2[num][0]&&cir[0][1]==cir2[num][1])
         {		//open if
         	hit=true;
            num=len2;

            setcolor(RED);
            settextstyle(COMPLEX_FONT,HORIZ_DIR,3);
   			settextjustify(CENTER_TEXT,CENTER_TEXT);
            outtextxy(320,220,"Player 1 ran into Player 2!");
         }		//close if
      }		//close for

      delay(speed);
   }		//close while
   if(dir2==KEY_A)		//holds the previous direction of the snake
   	olddir2='a';
   if(dir2==KEY_D)
   	olddir2='d';
   if(dir2==KEY_W)
   	olddir2='w';
   if(dir2==KEY_S)
   	olddir2='s';

   if(dir==KEY_LEFT)		//holds the previous direction of the snake
   	olddir='a';
   if(dir==KEY_RIGHT)
   	olddir='d';
   if(dir==KEY_UP)
   	olddir='w';
   if(dir==KEY_DOWN)
   	olddir='s';

   if(!hit)
   	dirhold=getch();		//holds the new direction of the snake

   if(dirhold=='p')		//to pause the game
   {		//open if
      setcolor(WHITE);
   	outtextxy(320,240,"Paused");

      dirhold=NULL;

      while(dirhold!='p')
      	dirhold=getch();

      setcolor(DARKGRAY);
      outtextxy(320,240,"Paused");
   }		//close if

   if(dirhold=='a'||dirhold=='s'||dirhold=='d'||dirhold=='w')
   {		//open if
   if(dirhold=='a')
   	dir2=KEY_A;
   if(dirhold=='d')
   	dir2=KEY_D;
   if(dirhold=='w')
   	dir2=KEY_W;
   if(dirhold=='s')
   	dir2=KEY_S;

   if(olddir2=='a'&&dir2==KEY_D)		//if the previous direction and the new
   	dir2=olddir2;                      //direction are opposites, set the new
   if(olddir2=='d'&&dir2==KEY_A)      //direction equal to the previous direction.
   	dir2=olddir2;
   if(olddir2=='w'&&dir2==KEY_S)
   	dir2=olddir2;
   if(olddir2=='s'&&dir2==KEY_W)
   	dir2=olddir2;

   if(dir2=='a')		//reinstates the new direction of the snake
   	dir2=KEY_A;
   if(dir2=='d')
   	dir2=KEY_D;
   if(dir2=='w')
   	dir2=KEY_W;
   if(dir2=='s')
   	dir2=KEY_S;
   }		//close if

   if(dirhold==KEY_UP||dirhold==KEY_DOWN||dirhold==KEY_LEFT||dirhold==KEY_RIGHT)
   {		//open if
   if(dirhold==KEY_UP)
   	dir=KEY_UP;
   if(dirhold==KEY_RIGHT)
   	dir=KEY_RIGHT;
   if(dirhold==KEY_DOWN)
   	dir=KEY_DOWN;
   if(dirhold==KEY_LEFT)
   	dir=KEY_LEFT;

   if(olddir=='a'&&dir==KEY_RIGHT)		//if the previous direction and the new
   	dir=olddir;                      //direction are opposites, set the new
   if(olddir=='d'&&dir==KEY_LEFT)      //direction equal to the previous direction.
   	dir=olddir;
   if(olddir=='w'&&dir==KEY_DOWN)
   	dir=olddir;
   if(olddir=='s'&&dir==KEY_UP)
   	dir=olddir;

   if(dir=='a')		//reinstates the new direction of the snake
   	dir=KEY_LEFT;
   if(dir=='d')
   	dir=KEY_RIGHT;
   if(dir=='w')
   	dir=KEY_UP;
   if(dir=='s')
   	dir=KEY_DOWN;
   }		//close if

   if(hit)
   	dirhold='q';
   }		//close while
}		//close movement2 function

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~NEWHS FUNCTION~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

void newhs(int score)

{		//open newhs function
   int rand1,rand2;
   char hold[5];

   for(num=0;num<5;num++)		//this is incase the user presses enter too fast
   {		//open for
   	rand1=random(16);
   	setbkcolor(rand1);
      settextstyle(COMPLEX_FONT,HORIZ_DIR,6);
      rand2=random(16);

      while(rand2==rand1)
      	rand2=random(16);

      setcolor(rand2);
      outtextxy(320,200,"NEW HIGH SCORE!!!");
      settextstyle(SIMPLEX_FONT,HORIZ_DIR,4);
      sprintf(hold, "%d",score);
      outtextxy(320,300,hold);

      settextstyle(SCRIPT_FONT,HORIZ_DIR,2);
      outtextxy(320,400,"Press any key to continue.");

      delay(500);
   }		//close for

	while(!kbhit())
   {		//open while
      rand1=random(16);
   	setbkcolor(rand1);
      settextstyle(COMPLEX_FONT,HORIZ_DIR,6);
      rand2=random(16);

      while(rand2==rand1)
      	rand2=random(16);

      setcolor(rand2);
      outtextxy(320,200,"NEW HIGH SCORE!!!");
      settextstyle(SIMPLEX_FONT,HORIZ_DIR,4);
      sprintf(hold, "%d",score);
      outtextxy(320,300,hold);

      settextstyle(SCRIPT_FONT,HORIZ_DIR,2);
      outtextxy(320,400,"Press any key to continue.");

      delay(500);
   }		//close while
   getch();
}		//close newhs function

/*~~~~~~~~~~~~~~~~~~~~~~~~~~INSTRUCTIONS FUNCTION~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

void instructions()

{		//open instructions function
   setcolor(WHITE);
   settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
   settextjustify(CENTER_TEXT,CENTER_TEXT);
	outtextxy(320,50,"Instructions");

   settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
   settextjustify(LEFT_TEXT,CENTER_TEXT);
   outtextxy(50,100,"The object of Snake is to eat as much food as you possibly");
   outtextxy(50,120,"can without running into the wall or yourself.");

   outtextxy(50,160,"Control the movement of the snake by using the arrow keys");
   outtextxy(50,180,"located on your keyboard.");

   outtextxy(50,220,"You may only move in directions perpendicular to your current direction.");

   outtextxy(50,260,"Navigate the snake to the food (the red circle) to gain points.");

   outtextxy(50,300,"The game ends when you hit the wall or yourself.");

   settextjustify(CENTER_TEXT,CENTER_TEXT);
   outtextxy(320,360,"2 Player Mode");

   settextjustify(LEFT_TEXT,CENTER_TEXT);
   outtextxy(50,400,"Player 1 is yellow and Player 2 is blue.");

   outtextxy(50,430,"You must also try to avoid hitting your team mate.");

   outtextxy(50,460,"You work together to gain as much points as possible.");

   getch();
}     //close instructions function

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~MENU FUNCTION~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

int menu()

{		//open menu function
   int pos;
   char x=0,y=0;

   setbkcolor(DARKGRAY);
   setcolor(GREEN);

   settextstyle(TRIPLEX_FONT,HORIZ_DIR,12);

   line(0,150,640,150);	//line between title and menu

   settextjustify(CENTER_TEXT,CENTER_TEXT);
   setcolor(WHITE);
   outtextxy(160,50,"S");
   outtextxy(240,50,"N");
   outtextxy(320,50,"A");
   outtextxy(400,50,"K");
   outtextxy(480,50,"E");		//title

   settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
   settextjustify(LEFT_TEXT,LEFT_TEXT);
   setcolor(RED);

   outtextxy(100,235,"Play Game");
   outtextxy(100,285,"Instructions");
   outtextxy(100,335,"Exit");

   setcolor(LIGHTGRAY);
   rectangle(60,220,200,340);

   setcolor(WHITE);
   outtextxy(150,450,"Written by Jason Robinson");

   setcolor(GREEN);
   arc(525,400,180,370,75);		//bottom bottom snake
   line(450,400,475,300);		//middle left snake
   arc(450,300,0,90,25);		//top bottom snake
   ellipse(540,400,180,370,57,50);		//top bottom arc
   line(597,393,598,388);              //close off tail
   line(482,400,500,280);		//middle right snake
   arc(475,280,0,90,25);		//top top snake
   line(475,255,450,263);		//top head snake
   ellipse(450,266,90,270,2,3);		//upper lip
   ellipse(450,272,90,270,2,3);     //lower lip
   setfillstyle(1,GREEN);
   floodfill(470,260,GREEN);		//fills the snake green
   setcolor(RED);
   ellipse(480,266,0,360,4,2);		//eye
   setfillstyle(1,RED);
   floodfill(480,266,RED);		//fills the eye red
   setcolor(DARKGRAY);
   circle(478,266,1);		//pupil
   line(478,266,478,266);		//pupil filler
   setcolor(DARKGRAY);
   line(449,269,454,269);		//line between lips

   setcolor(WHITE);
   for (num=0;num<6;num++)
   	circle(70,230,num);		//pointer drawn on position 1

   pos=1;		//position default on 1

   while (x!='\r')
   {		//open while
      while(!kbhit())
   	{		//open while
      	if(int ((clock()/CLK_TCK))%3==0)
      	{		//open if
   		setcolor(RED);
   		ellipse(445,269,0,180,3,1);		//tongue
   		ellipse(439,269,180,360,3,1);
         ellipse(444,269,0,180,3,1);
         ellipse(438,269,180,360,3,1);
   		line(436,269,434,267);		//tongue split
   		line(436,269,434,271);
         line(435,269,433,267);
         line(435,269,433,271);

      	delay(500);

      	setcolor(DARKGRAY);
      	ellipse(445,269,0,180,3,1);		//tongue
   		ellipse(439,269,180,360,3,1);
         ellipse(444,269,0,180,3,1);
         ellipse(438,269,180,360,3,1);
   		line(436,269,434,267);		//tongue split
   		line(436,269,434,271);
         line(435,269,433,267);
         line(435,269,433,271);
   		}		//close if
   	}		//close while
   	x=getch();

      if (x== KEY_UP)
      {		//open if
      	if (pos==1)
         {		//open nested if
            for (num=0;num<6;num++)
         	{		//open for
         	setcolor(DARKGRAY);
            circle(70,230,num);
            setcolor(WHITE);
            circle(70,330,num);
            }		//close for
            pos=3;
         }		//close nested if
         else if (pos==2)
         {		//open else if
            for (num=0;num<6;num++)
         	{		//open for
         	setcolor(DARKGRAY);
            circle(70,280,num);
            setcolor(WHITE);
            circle(70,230,num);
            }		//close for
            pos=1;
         }		//close else if
         else if (pos==3)
         {		//open else if
            for (num=0;num<6;num++)
         	{		//open for
         	setcolor(DARKGRAY);
            circle(70,330,num);
            setcolor(WHITE);
            circle(70,280,num);
            }		//close for
            pos=2;
         }		//close else if
      }		//close if

      if (x== KEY_DOWN)
      {		//open if
      	if (pos==1)
         {		//open nested if
            for (num=0;num<6;num++)
         	{		//open for
            setcolor(DARKGRAY);
            circle (70,230,num);
            setcolor(WHITE);
         	circle (70,280,num);
            }		//close for
            pos=2;
         }		//close nested if
         else if (pos==2)
         {		//open else if
            for (num=0;num<6;num++)
         	{		//open for
            setcolor(DARKGRAY);
            circle (70,280,num);
            setcolor(WHITE);
         	circle (70,330,num);
            }		//close for
            pos=3;
         }		//close else if
         else if (pos==3)
         {		//open else if
            for (num=0;num<6;num++)
         	{		//open for
         	setcolor(DARKGRAY);
            circle (70,330,num);
            setcolor(WHITE);
            circle (70,230,num);
            }		//close for
            pos=1;
         }		//close else if
      }		//close nested if
   }		//close while

   if(pos==1)
   {		//open if
      setcolor(WHITE);
   	outtextxy(115,255,"1P");
   	outtextxy(155,255,"2P");

      setcolor(RED);
      line(100,245,100,255);
      line(100,245,110,250);
      line(100,255,110,250);
      setfillstyle(1,RED);
      floodfill(105,250,RED);

      while (y!='\r')
   	{		//open while
      	y=getch();

         if(y==KEY_RIGHT)
         {		//open if
         	if(pos==1)
            {		//open if
               setcolor(WHITE);
               line(100,245,100,255);
               line(100,245,110,250);
               line(100,255,110,250);

            	setfillstyle(1,DARKGRAY);
               floodfill(105,250,WHITE);

               setcolor(DARKGRAY);
               line(100,245,100,255);
               line(100,245,110,250);
               line(100,255,110,250);

               setcolor(RED);
               line(140,245,140,255);
               line(140,245,150,250);
               line(140,255,150,250);
               setfillstyle(1,RED);
               floodfill(145,250,RED);

               pos=4;
            }		//close if
         }		//close if
         if(y==KEY_LEFT)
         {		//open if
         	if(pos==4)
            {		//open if
            	setcolor(WHITE);
               line(140,245,140,255);
               line(140,245,150,250);
               line(140,255,150,250);

            	setfillstyle(1,DARKGRAY);
               floodfill(145,250,WHITE);

               setcolor(DARKGRAY);
               line(140,245,140,255);
               line(140,245,150,250);
               line(140,255,150,250);

               setcolor(RED);
               line(100,245,100,255);
               line(100,245,110,250);
               line(100,255,110,250);
               setfillstyle(1,RED);
               floodfill(105,250,RED);

               pos=1;
            }		//close if
         }		//close if
      }		//close while
   }		//close if

   return pos;		//returns the position the pointer was last left in
}		//close menu function


Output:
1
2
3
4
5
6
7
Line 18: error: conio.h: No such file or directory
Line 16: error: dos.h: No such file or directory
Line 20: error: windows.h: No such file or directory
Line 24: error: dosgraphics.h: No such file or directory
Line 17: error: int9.h: No such file or directory
Line 35: error: '::main' must return 'int'
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: