Advertisement
Guest User

gdjgvh

a guest
Mar 26th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include "windows.h"
  4.  
  5. using namespace std;
  6.  
  7.  
  8. void punktyy(int *y, int *x, int *xp, int *ky ,int *pkt=0)
  9. {
  10.             if((*y==19)&&(*x>=*xp)&&(*x<=*xp+4))
  11.         {
  12.             *ky=-1**ky;
  13.             *pkt=*pkt+1;
  14.         }
  15. }
  16.  
  17.  
  18. void odbicie(int *x, int *y, int *kx,int *ky)
  19. {
  20.     if((*x>68)||(*x<3))
  21.         {
  22.             *kx=-1*(*kx);
  23.         }
  24.         *x=*x+*kx;
  25.         if((*y>20)||(*y<3))
  26.         {
  27.             *ky=-1**ky;
  28.         }
  29.         *y=*y+*ky;
  30.    
  31. }
  32.  
  33.  
  34. void gotoxy(int x,int y)
  35. {
  36.     COORD coord;
  37.     coord.X=x;
  38.     coord.Y=y;
  39.     SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
  40. }
  41. void logo ()
  42. {
  43.     int time=20;
  44.     cout<<"                              ,--."""<<endl; Sleep (time);
  45.     cout<<"                         __,----( o ))"<<endl; Sleep (time);
  46.     cout<<"                       ,'--.      , ( "<<endl; Sleep (time);
  47.     cout<<"                -"",:-(    o ),-'/  ;"<<endl; Sleep (time);
  48.     cout<<"                  ( o) `o  _,'\ / ;("<<endl; Sleep (time);
  49.     cout<<"                   `-;_-<'\_|-'/ '  )"<<endl; Sleep (time);
  50.     cout<<"                       `.`-.__/ '   |"<<endl; Sleep (time);
  51.     cout<<"          \`.            `. .__,   ;"<<endl; Sleep (time);
  52.     cout<<"           )_;--.         \`       |"<<endl; Sleep (time);
  53.     cout<<"          /'(__,-:         )      ;"<<endl; Sleep (time);
  54.     cout<<"        ;'    (_,-:     _,::     .|"<<endl; Sleep (time);
  55.     cout<<"       ;       ( , ) _,':::'    ,;"<<endl; Sleep (time);
  56.     cout<<"      ;         )-,;'  `:'     .::"<<endl; Sleep (time);
  57.     cout<<"      |         `'  ;         `:::\ "<<endl; Sleep (time);
  58.     cout<<"      :       ,'    '            `:\ "<<endl; Sleep (time);
  59.     cout<<"      ;:    '  _,-':         .'     `-."<<endl; Sleep (time);
  60.     cout<<"       ';::..,'  ' ,        `   ,__    `."<<endl; Sleep (time);
  61.     cout<<"         `;''   / ;           _;_,-'     `."<<endl; Sleep (time);
  62.     cout<<"               /            _;--.          \ "<<endl; Sleep (time);
  63.     cout<<"             ,'            / ,'  `.         \ "<<endl; Sleep (time);
  64.     cout<<"            /:            (_(   ,' \         )"<<endl; Sleep (time);
  65.     cout<<"           /:.               \_(  /-. .:::,;/"<<endl; Sleep (time);
  66.     cout<<"          ;::::.                    \        __ "<<endl; Sleep (time);
  67.     cout<<"          ,::::::.            .:'    )    ,-'  )"<<endl; Sleep (time);
  68.     cout<<"         /  `;:::::::'`__,:.:::'    /`---'   ,'"<<endl; Sleep (time);
  69.     cout<<"        ;    `""""'   (  \:::'     /     _,-'"<<endl; Sleep (time);
  70.     cout<<"        ;              \  \:'    ,';:.,-'"<<endl; Sleep (time);
  71.     cout<<"        (              :  )\    ("<<endl; Sleep (time);
  72.     cout<<"         `.             \   \    ;"<<endl; Sleep (time);
  73.     cout<<"           `-.___       : ,\ \  ("<<endl; Sleep (time);
  74.     cout<<"              ,','._::::| \ \ \  \ "<<endl; Sleep (time);
  75.     cout<<"             (,(,---;;;;;  \ \|;;;)"<<endl; Sleep (time);
  76.     cout<<"                         `._\_\ "<<endl; Sleep (time);
  77.     Sleep (2000);
  78.        
  79.  
  80.     for(int j=40;j>=0;j--)
  81.     {
  82.         for(int i=70;i>=0;i--)
  83.         {
  84.             Sleep(0);
  85.             gotoxy(i,j);
  86.             cout <<" ";
  87.         }
  88.     }
  89. }
  90.  
  91. void menu()
  92. {
  93.     int wybor;
  94.     cout<<"MENU GLOWNE"<<endl;
  95.     cout<<"------------"<<endl;
  96.     cout<<"1. Rozpocznij gre"<<endl;
  97.     cout<<"2. Opusc gre"<<endl;
  98.     cout<<"Wybor: ";cin>>wybor;
  99.    
  100.     switch (wybor)
  101.     {
  102.         case 1:
  103.         {
  104.             system ("CLS");
  105.             break;
  106.         }
  107.        
  108.         case 2:
  109.         {
  110.             exit (0);
  111.         }
  112.     }
  113. }
  114.  
  115. int main(int argc, char** argv)
  116. {
  117.     logo();
  118.     menu();
  119.    
  120.     int x=3;
  121.     int y=3;
  122.     int xp=3;
  123.     int kx=1, ky=1, kxp=1, pkt=0;
  124.     char aa;
  125.    
  126.     aa=218;
  127.     gotoxy(1,1);
  128.     cout<<aa;
  129.     aa=191;
  130.     gotoxy(70,1);
  131.     cout<<aa;
  132.     aa=192;
  133.     gotoxy(1,22);
  134.     cout<<aa;
  135.     aa=217;
  136.     gotoxy(70,22);
  137.     cout<<aa;
  138.    
  139.     aa=196;
  140.    
  141.     for (int i=2;i<70;i++)
  142.     {
  143.         gotoxy(i,1);
  144.         cout<<aa;
  145.         gotoxy(i,22);
  146.         cout<<aa<<endl;
  147.     }
  148.    
  149.     aa=179;
  150.    
  151.     for (int i=2;i<22;i++)
  152.     {
  153.         gotoxy(1,i);
  154.         cout<<aa;
  155.         gotoxy(70,i);
  156.         cout<<aa<<endl;
  157.     }
  158.    
  159.     char ee='q';
  160.     while(ee=='q')
  161.     {
  162.         gotoxy(x,y);
  163.         cout<<"o";
  164.         gotoxy(xp,19);
  165.         aa=196;
  166.         cout<<aa<<aa<<aa<<aa<<aa;
  167.        
  168.         Sleep(50);
  169.        
  170.         gotoxy(x,y);
  171.         cout<<" ";
  172.         gotoxy(xp,19);
  173.         cout<<"     ";
  174.        
  175.         punktyy(&y,&x,&xp,&ky,&pkt);
  176.        
  177.         if((xp>64) || (xp<3))
  178.         {
  179.             kxp=-1*kxp;
  180.         }
  181.         xp=xp+kxp;
  182.        
  183.         odbicie(&x,&y,&kx,&ky);
  184.        
  185.    
  186.        
  187.         char ch1;
  188.         while (_kbhit())
  189.         {
  190.             ch1=_getch();
  191.             if (ch1=='e')
  192.             {
  193.                 ee='e';
  194.             }
  195.             if (ch1=' ')
  196.             {
  197.                 kxp=-1*kxp;
  198.             }
  199.         }
  200.        
  201.         gotoxy(75,10);
  202.         cout<<punktyy<<endl;
  203.        
  204.     }
  205.    
  206.  
  207.    
  208.     return 0;
  209. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement