Advertisement
Guest User

Shooter game

a guest
May 15th, 2014
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 15.23 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <windows.h>
  4. #include <stdlib.h>
  5. #include <conio.h>
  6. #include <stdio.h>
  7.  
  8. using namespace std;
  9.  
  10.  
  11.  COORD coord={0,0}; // this is global variable
  12.                                     //center of axis is set to the top left cornor of the screen
  13.  void gotoxy(int x,int y)
  14.  {
  15.    coord.X=x;
  16.  coord.Y=y;
  17.  SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
  18.  }
  19.  int x, y, lastx, lasty, x2, y2;
  20.  int x1, y1, astx, asty;
  21. char a;
  22. char ch;
  23.  
  24.   int main()
  25. {
  26.  
  27.  
  28. char Z = 254;
  29.     char q, ch1;
  30.     char a = 221, b=219;
  31.     int i;
  32.     char l = 3;
  33.     char hit = getch();
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.   system("color 13");
  41.       Beep(261,100);
  42.   Beep(293,100);
  43.    Beep(329,100);
  44.   Beep(349,100);
  45.  
  46.    cout<<"        ***********           ***********      999999999999999         00000000000000\n";
  47. Sleep(100);
  48.    cout<<"        **** *******        *******  ****      999999999999999         00          00\n";
  49.    Sleep(100);
  50.    cout<<"        ****  ********      ******   ****      999         999         00           00\n";
  51.    Sleep(100);
  52.    cout<<"        ****    *******    *******   ****      999         999         00            00\n";
  53.    Sleep(100);
  54.    cout<<"        ****     *******  *******    ****      999         999         00             00\n";
  55.    Sleep(100);
  56.    cout<<"        ****      **************     ****      999         999         00              00\n";
  57.    Sleep(100);
  58.    cout<<"        ****         ********        ****      999         999         00              00\n";
  59.    Sleep(100);
  60.    cout<<"        ****          ******         ****      999         999         00              00\n";
  61.    Sleep(100);
  62.    cout<<"        ****                         ****      999         999         00              00\n";
  63.    Sleep(100);
  64.    cout<<"        ****                         ****      999         999         00              00\n";
  65.    Sleep(100);
  66.    cout<<"        ****                         ****      999         999         00              00\n";
  67.    Sleep(100);
  68.    cout<<"        ****                         ****      999         999         00              00\n";
  69.    Sleep(100);
  70.    cout<<"        ****                         ****      999         999         00             00\n";
  71.    Sleep(100);
  72.    cout<<"        ****                         ****      999         999         00            00\n";
  73.    Sleep(100);
  74.    cout<<"        ****                         ****      999         999         00           00\n";
  75.    Sleep(100);
  76.    cout<<"        ****                         ****      999         999         00          00\n";
  77.    Sleep(100);
  78.    cout<<"        ****                         ****      999999999999999         00         00\n";
  79.    Sleep(100);
  80.    cout<<"        ****                         ****      999999999999999         0000000000000\n";
  81.  
  82.    cout<<"\n\n                                         PRESS ENTER TO PLAY";
  83.  
  84.  
  85.    cin.ignore();
  86.          system("color 1C");
  87.          Sleep(50);
  88.          system("color 14");
  89.          Sleep(50);
  90.          system("color 15");
  91.          Sleep(50);
  92.          system("color 16");
  93.          Sleep(50);
  94.          system("color 19");
  95.          Sleep(50);
  96.          system("color 14");
  97.          for(q = 0; q<120; q++){
  98.             cout<<a;
  99.             Sleep(60);
  100.          }
  101.          system("CLS");
  102. //***************************************************************************************************************************************************************
  103. system("color 27");
  104.  
  105.  
  106.      do
  107.        {
  108.         ch1 = getch();
  109.         switch(ch1)
  110.         {
  111.             case 'W':
  112.             case 'w':
  113.                 system("CLS");
  114.                 system("color 09");
  115.                 cout<<"                                                         *-=MOD=-* v1.0\n\n\n\n\n\n\n\n\n\n\n\n\n";
  116.             cout<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<endl;
  117.             cout<<b<<"                                                      --> PLAY                                                 "                                                                                                                                                                  <<b<<endl;
  118.             cout<<b<<"                                                          HELP                                                 "                                                                                                                                                                                                       <<b<<endl;
  119.             cout<<b<<"                                                          EXIT                                                 "                                                                                                                                                                                                       <<b<<endl;
  120.             cout<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b;
  121.             cin.get();
  122.             case '13':
  123.                 cin.ignore();
  124.                 system("CLS");
  125.                 cout<<"      "<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<endl;
  126.         cout<<"      "<<b<<endl;
  127.         cout<<"      "<<b<<endl;
  128.         cout<<"      "<<b<<endl;
  129.         cout<<"      "<<b<<endl;
  130.         cout<<"      "<<b<<endl;
  131.         cout<<"      "<<b<<endl;
  132.         cout<<"      "<<b<<endl;
  133.         cout<<"      "<<b<<endl;
  134.         cout<<"      "<<b<<endl;
  135.         cout<<"      "<<b<<endl;
  136.         cout<<"      "<<b<<endl;
  137.         cout<<"      "<<b<<endl;
  138.         cout<<"      "<<b<<endl;
  139.         cout<<"      "<<b<<endl;
  140.         cout<<"      "<<b<<endl;
  141.         cout<<"      "<<b<<endl;
  142.         cout<<"      "<<b<<endl;
  143.         cout<<"      "<<b<<endl;
  144.         cout<<"      "<<b<<endl;
  145.         cout<<"      "<<b<<endl;
  146.         cout<<"      "<<b<<endl;
  147.         cout<<"      "<<b<<endl;
  148.         cout<<"      "<<b<<endl;
  149.         cout<<"      "<<b<<endl;
  150.         cout<<"      "<<b<<endl;
  151.         cout<<"      "<<b<<endl;
  152.         cout<<"      "<<b<<endl;
  153.         cout<<"      "<<b<<endl;
  154.         cout<<"      "<<b<<endl;
  155.         cout<<"      "<<b<<endl;
  156.         cout<<"      "<<b<<endl;
  157.         cout<<"      "<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<endl;
  158.  
  159.  
  160.        gotoxy(103,1);
  161.        cout<<b<<endl;
  162.        gotoxy(103,2);
  163.        cout<<b<<endl;
  164.        gotoxy(103,3);
  165.        cout<<b<<endl;
  166.        gotoxy(103,4);
  167.        cout<<b<<endl;
  168.        gotoxy(103,5);
  169.        cout<<b<<endl;
  170.        gotoxy(103,6);
  171.        cout<<b<<endl;
  172.        gotoxy(103,7);
  173.        cout<<b<<endl;
  174.        gotoxy(103,8);
  175.        cout<<b<<endl;
  176.        gotoxy(103,9);
  177.        cout<<b<<endl;
  178.        gotoxy(103,10);
  179.        cout<<b<<endl;
  180.        gotoxy(103,11);
  181.        cout<<b<<endl;
  182.        gotoxy(103,12);
  183.        cout<<b<<endl;
  184.        gotoxy(103,13);
  185.        cout<<b<<endl;
  186.        gotoxy(103,14);
  187.        cout<<b<<endl;
  188.        gotoxy(103,15);
  189.        cout<<b<<endl;
  190.        gotoxy(103,16);
  191.        cout<<b<<endl;
  192.        gotoxy(103,17);
  193.        cout<<b<<endl;
  194.        gotoxy(103,18);
  195.        cout<<b<<endl;
  196.        gotoxy(103,19);
  197.        cout<<b<<endl;
  198.        gotoxy(103,20);
  199.        cout<<b<<endl;
  200.        gotoxy(103,21);
  201.        cout<<b<<endl;
  202.        gotoxy(103,22);
  203.        cout<<b<<endl;
  204.        gotoxy(103,23);
  205.        cout<<b<<endl;
  206.        gotoxy(103,24);
  207.        cout<<b<<endl;
  208.        gotoxy(103,25);
  209.        cout<<b<<endl;
  210.        gotoxy(103,26);
  211.        cout<<b<<endl;
  212.        gotoxy(103,27);
  213.        cout<<b<<endl;
  214.        gotoxy(103,28);
  215.        cout<<b<<endl;
  216.        gotoxy(103,29);
  217.        cout<<b<<endl;
  218.        gotoxy(103,30);
  219.        cout<<b<<endl;
  220.        gotoxy(103,31);
  221.        cout<<b<<endl;
  222.        gotoxy(2,34);
  223.        cout<<"                                                   LIVES:"<<l<<l<<l<<endl;
  224.        gotoxy(2,36);
  225.        cout<<"                                                   SCORE: ---";
  226.  
  227.        x = 50; y = 31;
  228.  
  229.  
  230.       lastx = x; lasty = y;
  231.       x2 = lastx; y2 = lasty;
  232.         while(2 == 2)
  233.  
  234.  {
  235.  
  236.  gotoxy(lastx, lasty);
  237.  printf("         ");
  238.  gotoxy(x,y);
  239.  printf("**|_A_|**");
  240.  a = getch();
  241.  lastx = x; lasty = y;
  242.  if (a == 77) x = x + 1;
  243.  if (a == 75) x = x - 1;
  244.  
  245.  }
  246.  while(1 == 1){
  247.     gotoxy(x,y);
  248.       printf("       ");
  249. x1 = rand() % 3 + 50 ; y1 = 1;
  250.  gotoxy(x1,y1);
  251.  
  252.  
  253.  std::cout<<"|"<<Z<<"|";
  254.  
  255.  Sleep(500);
  256.  
  257.  }
  258.  
  259.   if(hit == ' '){
  260.         while(true){
  261.     gotoxy(x,y);
  262.       printf(" ");
  263. x2; y2 = lasty + 1;
  264.  printf("^");
  265.  Sleep(200);
  266.         }
  267.  }
  268.                 break;
  269.             break;
  270.             case 'E':
  271.             case 'e':
  272.                 system("CLS");
  273.                 system("color 02");
  274.             cout<<"                                                         *-=MOD=-* v1.0\n\n\n\n\n\n\n\n\n\n\n\n\n";
  275.             cout<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<endl;
  276.             cout<<b<<"                                                         PLAY                                                  "                                                                                                                                                                                                       <<b<<endl;
  277.             cout<<b<<"                                                     --> HELP                                                  "                                                                                                                                                                  <<b<<endl;
  278.             cout<<b<<"                                                         EXIT                                                  "                                                                                                                                                                                                       <<b<<endl;
  279.             cout<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<endl;
  280.             case '13':
  281.                 cin.ignore();
  282.                 system("CLS");
  283.                 cout<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<endl;
  284.                 cout<<"                                                  *-=INSTRUCTIONS=-*\n";
  285.                 cout<<"                                                   ______________\n\n\n\n\n";
  286.  
  287.                 system("color 06");
  288.                 cout<<"                           The asteroids are falling from the sky, The fate of Earth depends on you.";
  289.                 cout<<"\n                                    Destroy the Asteroids before they reach the end!";
  290.                 cout<<"\n\n                                               LET THE GAMES BEGIN";
  291.                 cout<<"\n\n\n                                                 CONTROLS\n\n";
  292.                 cout<<"                                     <-- (RIGHT ARROW)    -   Ship goes right\n";
  293.                 cout<<"                                     --> (LEFT ARROW)     -   Ship goes left\n";
  294.                 cout<<"                                     ==  (SPACE)          -   Ship shoots\n";
  295.                 cout<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<endl;
  296.  
  297.                 break;
  298.  
  299.  
  300.             break;
  301.             case 'R':
  302.             case 'r':
  303.                 system("CLS");
  304.                 system("color 0C");
  305.             cout<<"                                                         *-=MOD=-* v1.0\n\n\n\n\n\n\n\n\n\n\n\n\n";
  306.             cout<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<endl;
  307.             cout<<b<<"                                                          PLAY                                                 "                                                                                                                                                                                                       <<b<<endl;
  308.             cout<<b<<"                                                          HELP                                                 "                                                                                                                                                                                                       <<b<<endl;
  309.            cout<<b<<"                                                      --> EXIT                                                 "                                                                                                                                                                  <<b<<endl;
  310.             cout<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<endl;
  311.             break;
  312.         }
  313.     }while (ch != 'Q' && ch!='q');
  314.  
  315. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement