a pastebin project

Paste Description for Hero - The Game

http://www.bin-co.com/cpp/

Hero - The Game

  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<process.h>
  4. #include<stdlib.h>
  5. #include<dos.h>
  6.  
  7. static int min=1;
  8. static int sec=59;
  9. static int micro=59;
  10. static int col=2;
  11. static int col1=76;
  12. static int row=9;
  13. static int row5=5;
  14. static int row13=13;
  15. static int row17=17;
  16. static int row21=21;
  17. int b=5;
  18.  
  19. int crow1=3,ccol1=2;
  20. char cha[25][80];
  21. void intro();
  22. void arrow();
  23.  
  24.  
  25. void main(void)//date completed ( 11 / 9 / 2007 Sep )
  26. {
  27.  
  28.         char ch,get;
  29.         int row,row1;
  30.         const int ESC=27,LEFT=75,RIGHT=77,UP=72,DOWN=80;
  31.         int a;
  32.         int score1=0;
  33.         clrscr();
  34.         intro();
  35.  
  36.  
  37.  
  38.         clrscr();
  39.  
  40.         for(int i=0;i<25;i++)
  41.         for(int j=0;j<80;j++)
  42.         cha[i][j]='y';
  43.  
  44.  
  45.         textbackground(14); textcolor(11);
  46.         gotoxy(6,1);cprintf(" SCORE :       LAST TIME :                 CHANCE :        EXIT : Esc ");
  47.         textbackground(0);
  48.         textcolor(RED);
  49.         gotoxy(1,2);cprintf("ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»");
  50.                 textcolor(14);
  51.                 gotoxy(1,3);cprintf("¯");
  52.                 gotoxy(80,23);cprintf("¯");
  53.                 textcolor(RED);
  54.         for(row=4;row<=24;row++)
  55.                 {
  56.                 gotoxy(1,row);cprintf("º");
  57.                 }
  58.         for(row1=3;row1<=22;row1++)
  59.                 {
  60.                 gotoxy(80,row1);cprintf("º");
  61.                 }
  62.  
  63.         gotoxy(1,24);cprintf("ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ");
  64.  
  65.         textcolor(2);
  66.         textbackground(0);
  67.         gotoxy(2,4); cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  68.         gotoxy(16,4);cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  69.         gotoxy(42,4);cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  70.         gotoxy(68,4);cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛ");
  71.  
  72.         gotoxy(2,6); cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  73.         gotoxy(28,6);cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  74.         gotoxy(54,6);cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  75.  
  76.         gotoxy(2,8); cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  77.         gotoxy(16,8);cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  78.         gotoxy(42,8);cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  79.         gotoxy(68,8);cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛ");
  80.  
  81.         gotoxy(2,10); cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  82.         gotoxy(28,10);cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  83.         gotoxy(54,10);cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  84.  
  85.         gotoxy(2,12); cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  86.         gotoxy(16,12);cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  87.         gotoxy(42,12);cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  88.         gotoxy(68,12);cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛ");
  89.  
  90.         gotoxy(2,14); cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  91.         gotoxy(28,14);cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  92.         gotoxy(54,14);cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  93.  
  94.         gotoxy(2,16); cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  95.         gotoxy(16,16);cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  96.         gotoxy(42,16);cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  97.         gotoxy(68,16);cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛ");
  98.  
  99.         gotoxy(2,18); cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  100.         gotoxy(28,18);cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  101.         gotoxy(54,18);cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  102.  
  103.         gotoxy(2,20); cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  104.         gotoxy(16,20);cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  105.         gotoxy(42,20);cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  106.         gotoxy(68,20);cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛ");
  107.  
  108.         gotoxy(2,22); cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  109.         gotoxy(28,22);cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
  110.         gotoxy(54,22);cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛb");
  111. //--------------------------------------------------------------------
  112.         textcolor(13);
  113.         gotoxy(5,3);cprintf  ("");
  114.         gotoxy(2,7);cprintf  ("");
  115.         gotoxy(2,11);cprintf ("");
  116.         gotoxy(2,15);cprintf ("");
  117.         gotoxy(2,19);cprintf ("");
  118.         gotoxy(2,23);cprintf ("");
  119.  
  120.  
  121. do
  122. {
  123.  
  124.  
  125.                 arrow();
  126.                 ch=getch();
  127.  
  128.                 textcolor(0);textbackground(0);
  129.  
  130.                 gotoxy(ccol1,crow1);cprintf("Ûb");
  131.  
  132.         if(ch==RIGHT&& ccol1!=79 && (crow1!=4 && crow1!=6 && crow1!=8 && crow1!=10 && crow1!=12 && crow1!=14 && crow1!=16 && crow1!=18 && crow1!=20 && crow1!=22) )
  133.         {
  134.                 ccol1++;
  135.         }
  136.         if(ch==LEFT && ccol1!= 2 && (crow1!=4 && crow1!=6 && crow1!=8 && crow1!=10 && crow1!=12 && crow1!=14 && crow1!=16 && crow1!=18 && crow1!=20 && crow1!=22))
  137.         {
  138.                 ccol1--;
  139.         }
  140.         if(ch==DOWN && crow1!=23)
  141.         {
  142.                 if((crow1==3 || crow1==4 || crow1==7 || crow1==8 || crow1==11 || crow1==12 || crow1==15 || crow1==16 || crow1==19 || crow1==20) && (ccol1==15 || ccol1==41 || ccol1==67))
  143.                 {
  144.                 crow1++;
  145.                 }
  146.  
  147.                 if((crow1==5 || crow1==6 || crow1==9 || crow1==10 || crow1==13 || crow1==14 || crow1==17 || crow1==18 || crow1==21 || crow1==22) && (ccol1==27 || ccol1==53))
  148.                 {
  149.                 crow1++;
  150.                 }
  151.         }
  152.         if(ch==UP   && crow1!= 3)
  153.         {
  154.                 if((crow1==4 || crow1==5 || crow1==8 || crow1==9 || crow1==12 || crow1==13 || crow1==16 || crow1==17 || crow1==20|| crow1==21) && (ccol1==15 || ccol1==41 || ccol1==67))
  155.                 {
  156.                 crow1--;
  157.                 }
  158.                 if((crow1==6 || crow1==7 || crow1==10 || crow1==11 || crow1==14 || crow1==15 || crow1==18 || crow1==19 || crow1==22|| crow1==23) && (ccol1==27 || ccol1==53))
  159.                 {
  160.                 crow1--;
  161.                 }
  162.         }
  163.  
  164.         if( (crow1==3) && ((ccol1>=5) && (ccol1<=79)) || (crow1==7) && ((ccol1>=2) && (ccol1<=79)) || (crow1==11) && ((ccol1>=2) && (ccol1<=79))  || (crow1==15) && ((ccol1>=2) && (ccol1<=79))  || (crow1==19) && ((ccol1>=2) && (ccol1<=79))  || (crow1==23) && ((ccol1>=2) && (ccol1<=79)))
  165.         {
  166.                 if(cha[crow1][ccol1]=='y')
  167.                 {
  168.                 cha[crow1][ccol1]='n';
  169.                 score1++;
  170.                 }
  171.         }
  172.  
  173.         if( (crow1==23 && ccol1==79) )
  174.         {
  175.                 gotoxy(20,11);printf("                                   ");
  176.                 gotoxy(20,12);printf("           CONGRATULATION          ");
  177.                 gotoxy(20,13);printf("                                   ");
  178.                 gotoxy(20,14);printf("          YOUR SCORE  %0.3d         ",score1);
  179.                 gotoxy(20,15);printf("                                   ");
  180.                 gotoxy(20,16);printf("              GAME OVER            ");
  181.                 gotoxy(20,17);printf("                                   ");
  182.  
  183.  
  184.                 getch();
  185.                 getch();
  186.  
  187.                 exit(1);
  188.         }
  189.  
  190.         textcolor(14); textbackground(6);
  191.         gotoxy (15,1); cprintf("%03d",score1);
  192.         gotoxy (58,1); cprintf(" %02d",b);
  193.  
  194.         textbackground (0);
  195.                 textcolor(15);
  196.  
  197.                 gotoxy(ccol1,crow1);cprintf("Ûb");
  198.  
  199. }while(ch!=ESC);
  200.  
  201.  
  202. clrscr();
  203. }
  204.  
  205. //---------------------------------------------------------
  206. void arrow( )
  207. {
  208.         static int a=1;
  209.         do
  210.         {
  211. //--------------------Time        ---------------------
  212.         micro--;
  213.         if(micro==0)
  214.                 {
  215.                 micro=60;
  216.                 sec--;
  217.                 }
  218.         if(sec==0)
  219.                 {
  220.                 sec=60;
  221.                 min--;
  222.                 }
  223.  
  224.         if( (min==0)  || (b==0))
  225.                 {
  226.                 gotoxy(20,9); printf ("                               ");
  227.                 gotoxy(20,10);printf (" Sorry  You Have to go to exit ");
  228.                 gotoxy(20,11);printf ("                               ");
  229.                 gotoxy(20,12);printf ("     Press Any Key to Exit     ");
  230.                 gotoxy(20,14);printf ("                               ");
  231.  
  232.                 getch();
  233.                 getch();
  234.                 exit(1);
  235.                 }
  236.         gotoxy(35,1);printf("%02d:%02d:%02db",min,sec,micro);
  237.  
  238. //----------------Arrow ---------------------------
  239.  
  240.         if(a==1)
  241.         {
  242.                 textcolor(0);
  243.                 gotoxy (col,row5 ); cprintf("    ");
  244.                 gotoxy (col1,row  ); cprintf("    ");
  245.                 gotoxy (col,row13); cprintf("    ");
  246.                 gotoxy (col1,row17); cprintf("    ");
  247.                 gotoxy (col,row21); cprintf("    ");
  248.  
  249.                 col++;col1--;textcolor(15);
  250.  
  251.                 gotoxy (col,row5 ); cprintf("--->");
  252.                 gotoxy (col1,row  ); cprintf("===");
  253.                 gotoxy (col,row13); cprintf("--->");
  254.                 gotoxy (col1,row17); cprintf("---");
  255.                 gotoxy (col,row21); cprintf("--->");
  256.                 delay(10);
  257.  
  258.                 if( (col==76) && (col1==2))a=0;
  259.         }
  260.  
  261.         if(a==0)
  262.         {
  263.                 textcolor(0);
  264.                 gotoxy (col,row5 ); cprintf("    ");
  265.                 gotoxy (col1,row  ); cprintf("     ");
  266.                 gotoxy (col,row13); cprintf("    ");
  267.                 gotoxy (col1,row17); cprintf("    ");
  268.                 gotoxy (col,row21); cprintf("    ");
  269.  
  270.                 col--;col1++;textcolor(15);
  271.  
  272.                 gotoxy (col,row5 ); cprintf("<---");
  273.                 gotoxy (col1,row  ); cprintf("===");
  274.                 gotoxy (col,row13); cprintf("<---");
  275.                 gotoxy (col1,row17); cprintf("---");
  276.                 gotoxy (col,row21); cprintf("<---");
  277.                 delay(10);
  278.  
  279.                 if(col==2)a=1;
  280.         }
  281.  
  282.         if(  ((col1==ccol1) && (row==crow1)) ||  ((col==ccol1) && (row5==crow1)) ||  ((col==ccol1)&& (row13==crow1)) ||  ((col1==ccol1)&& (row17==crow1))||  ((col==ccol1)&& (row21==crow1)))
  283.                 {
  284.                 b--;
  285.                 sound(1000);
  286.                 delay(1000);
  287.                 nosound();
  288.                 ccol1=2;
  289.                 crow1=3;
  290.                 micro=59;min=1;sec=59;
  291.                 }
  292.  
  293.         delay(8);
  294.         }while(!kbhit());
  295. }
  296. //--------------------------------------------------------------------------
  297. void intro()
  298. {
  299.         gotoxy(35,1);printf("786");
  300.  
  301.         textbackground(14);
  302.         textcolor(2);
  303.         gotoxy(20,5);cprintf("    W  E  L  L     C  O  M  E      ");
  304.  
  305.         textbackground(0);
  306.  
  307.         gotoxy(20,8);cprintf("  T H E  -  H E R O  -   G A M E       ");
  308.  
  309.  
  310.         textbackground(0);
  311.         textcolor(15);
  312.         gotoxy(7,12);cprintf(" COMPOSED BY : ");
  313.         textbackground(10);
  314.         textcolor(9+150);
  315.         gotoxy(20,14);cprintf("   S A J I D   A L I   T U N I O  bb ");
  316.         gotoxy(40,16);cprintf("[Group Leader]");
  317.         textbackground(1);
  318.         textcolor(9+150);
  319.  
  320.         gotoxy(20,18);cprintf("Members:");
  321.         gotoxy(20,20);cprintf("Majid Ali Soomro  ");
  322.         gotoxy(20,21);cprintf("Ali Hassan Gorar  ");
  323.         gotoxy(20,22);cprintf("Rashid Ali        ");
  324.         gotoxy(20,23);cprintf("Raja Jamshed      ");
  325.  
  326.  
  327.         getch();
  328.         textbackground(0); textcolor(15);
  329. }

advertising

Create a Paste

Please enter your new post below (or upload a file instead):





Please note that information posted here will not expire by default. If you want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords.

worth-right
worth-right
fantasy-obligation