Advertisement
Guest User

gdjgvh

a guest
Mar 26th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.51 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.     int punkty=0;
  125.     char aa;
  126.    
  127.     aa=218;
  128.     gotoxy(1,1);
  129.     cout<<aa;
  130.     aa=191;
  131.     gotoxy(70,1);
  132.     cout<<aa;
  133.     aa=192;
  134.     gotoxy(1,22);
  135.     cout<<aa;
  136.     aa=217;
  137.     gotoxy(70,22);
  138.     cout<<aa;
  139.    
  140.     aa=196;
  141.    
  142.     for (int i=2;i<70;i++)
  143.     {
  144.         gotoxy(i,1);
  145.         cout<<aa;
  146.         gotoxy(i,22);
  147.         cout<<aa<<endl;
  148.     }
  149.    
  150.     aa=179;
  151.    
  152.     for (int i=2;i<22;i++)
  153.     {
  154.         gotoxy(1,i);
  155.         cout<<aa;
  156.         gotoxy(70,i);
  157.         cout<<aa<<endl;
  158.     }
  159.    
  160.     char ee='q';
  161.     while(ee=='q')
  162.     {
  163.         gotoxy(x,y);
  164.         cout<<"o";
  165.         gotoxy(xp,19);
  166.         aa=196;
  167.         cout<<aa<<aa<<aa<<aa<<aa;
  168.        
  169.         Sleep(50);
  170.        
  171.         gotoxy(x,y);
  172.         cout<<" ";
  173.         gotoxy(xp,19);
  174.         cout<<"     ";
  175.        
  176.         punktyy(&y,&x,&xp,&ky,&pkt);
  177.        
  178.         if((xp>64) || (xp<3))
  179.         {
  180.             kxp=-1*kxp;
  181.         }
  182.         xp=xp+kxp;
  183.        
  184.         odbicie(&x,&y,&kx,&ky);
  185.        
  186.    
  187.        
  188.         char ch1;
  189.         while (_kbhit())
  190.         {
  191.             ch1=_getch();
  192.             if (ch1=='e')
  193.             {
  194.                 ee='e';
  195.             }
  196.             if (ch1=' ')
  197.             {
  198.                 kxp=-1*kxp;
  199.             }
  200.         }
  201.        
  202.         gotoxy(75,10);
  203.         cout<<punktyy<<endl;
  204.        
  205.     }
  206.    
  207.  
  208.    
  209.     return 0;
  210. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement