Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.74 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. #include <stdio.h>
  4.  
  5. #include <conio.h>
  6.  
  7. #include <Windows.h>
  8.  
  9. #include <string>
  10.  
  11. using namespace std;
  12.  
  13. void gotoxy(int x, int y)
  14.  
  15. {
  16.  
  17.     COORD coord;
  18.  
  19.     coord.X = x;
  20.  
  21.     coord.Y = y;
  22.  
  23.     SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
  24.  
  25. }
  26.  
  27. void logo()
  28.  
  29. {
  30.  
  31.     gotoxy(1, 1);
  32.     std::cout << "                                                                                 " << std::endl;
  33.     std::cout << "   _|_|    _|_|_|    _|    _|    _|_|    _|      _|    _|_|    _|_|_|  _|_|_|    " << std::endl;
  34.     std::cout << " _|    _|  _|    _|  _|  _|    _|    _|  _|_|    _|  _|    _|    _|    _|    _|  " << std::endl;
  35.     std::cout << " _|_|_|_|  _|_|_|    _|_|      _|_|_|_|  _|  _|  _|  _|    _|    _|    _|    _|  " << std::endl;
  36.     std::cout << " _|    _|  _|    _|  _|  _|    _|    _|  _|    _|_|  _|    _|    _|    _|    _|  " << std::endl;
  37.     std::cout << " _|    _|  _|    _|  _|    _|  _|    _|  _|      _|    _|_|    _|_|_|  _|_|_|    " << std::endl;
  38.     std::cout << "                                                                                 " << std::endl;
  39.  
  40.     Sleep(2000);
  41.  
  42.     for (int i = 7; i > 0; i--)
  43.  
  44.     {
  45.  
  46.         gotoxy(1, i);
  47.  
  48.         cout << "                                                                                                 " << endl;
  49.  
  50.         Sleep(50);
  51.  
  52.     }
  53.  
  54.     system("cls");
  55.  
  56. }
  57.  
  58. void pp(int aa)
  59. {
  60.  
  61.     gotoxy(75, 10); std::cout << "Punkty:" << aa;
  62.  
  63. }
  64.  
  65. void menu()
  66. {
  67.     cout << "              " << endl;
  68.     cout << "    ==========" << endl;
  69.     cout << "    ===MENU===" << endl;
  70.     cout << "    =ARKANOID=" << endl;
  71.     cout << "    ==========" << endl;
  72.     cout << "1. Rozpocznij gre\n" << "2. Informacja o autorze" << endl << "3. Zamknij program" << endl;
  73. }
  74. void gra()
  75. {
  76.     logo();
  77.  
  78.     int punkty = 0;
  79.     int x = 3;
  80.  
  81.     int y = 3;
  82.  
  83.     int xp = 3; //x paletki
  84.  
  85.     int kxp = 1; //kierunek x paletki
  86.  
  87.     int kx = 1;
  88.  
  89.     int ky = 1;
  90.  
  91.     char aa;
  92.  
  93.     aa = 218; //z kodu asci
  94.  
  95.     gotoxy(1, 1); //lewy gorny naroznik
  96.  
  97.     cout << aa;
  98.  
  99.     aa = 192;
  100.  
  101.     gotoxy(1, 22); //prawy gorny naroznik
  102.  
  103.     cout << aa;
  104.  
  105.     aa = 217;
  106.  
  107.     gotoxy(70, 22); //prawy dolny naroznik
  108.  
  109.     cout << aa;
  110.  
  111.     aa = 191;
  112.  
  113.     gotoxy(70, 1); //lewy dolny naroznik
  114.  
  115.     cout << aa;
  116.  
  117.     aa = 196;
  118.  
  119.     //ramka 70x22
  120.  
  121.     for (int i = 2; i < 70; i++)
  122.  
  123.     {
  124.  
  125.         gotoxy(i, 1);
  126.  
  127.         cout << aa;
  128.  
  129.     }
  130.  
  131.     aa = 179;
  132.  
  133.     for (int i = 2; i < 22; i++)
  134.  
  135.     {
  136.  
  137.         gotoxy(1, i);
  138.  
  139.         cout << aa;
  140.  
  141.     }
  142.  
  143.     aa = 196;
  144.  
  145.     for (int i = 2; i < 70; i++)
  146.  
  147.     {
  148.  
  149.         gotoxy(i, 22);
  150.  
  151.         cout << aa;
  152.  
  153.     }
  154.  
  155.     aa = 179;
  156.  
  157.     for (int i = 2; i < 22; i++)
  158.  
  159.     {
  160.  
  161.         gotoxy(70, i);
  162.  
  163.         cout << aa;
  164.  
  165.     }
  166.  
  167.     char ee = 'q';
  168.  
  169.     while (ee == 'q')
  170.  
  171.     {
  172.  
  173.         gotoxy(x, y);
  174.  
  175.         cout << "o"; //piłeczka
  176.  
  177.         gotoxy(xp, 19); //kordy paletki
  178.  
  179.         aa = 196;
  180.  
  181.         cout << aa << aa << aa << aa << aa;
  182.  
  183.         Sleep(50);
  184.  
  185.         gotoxy(x, y);
  186.  
  187.         cout << " ";
  188.  
  189.         gotoxy(xp, 19);
  190.  
  191.         cout << "     ";
  192.  
  193.  
  194.  
  195.         //odbicie
  196.  
  197.         if ((xp > 64) || (xp < 3))
  198.  
  199.         {
  200.  
  201.             kxp = -1 * kxp;
  202.  
  203.         }
  204.  
  205.         xp = xp + kxp;
  206.  
  207.         if ((x > 67) || (x < 3))
  208.  
  209.         {
  210.  
  211.             kx = -1 * kx;
  212.  
  213.         }
  214.  
  215.         x = x + kx;
  216.  
  217.         if ((y > 20) || (y < 3))
  218.  
  219.         {
  220.  
  221.             ky = -1 * ky;
  222.  
  223.         }
  224.  
  225.         y = y + ky;
  226.  
  227.         if ((y == 19) && (x >= xp) && (x <= xp + 4))
  228.  
  229.         {
  230.  
  231.             ky = -1 * ky;
  232.             punkty = punkty + 1;
  233.         }
  234.  
  235.         char ch1;
  236.  
  237.         while (_kbhit())
  238.  
  239.         {
  240.  
  241.             ch1 = _getch();
  242.  
  243.             if (ch1 == 'e')
  244.  
  245.             {
  246.  
  247.                 ee = 'e';
  248.  
  249.             }
  250.  
  251.             if (ch1 == ' ')
  252.  
  253.             {
  254.  
  255.                 kxp = -1 * kxp;
  256.  
  257.             }
  258.  
  259.         }
  260.         pp(punkty);
  261.     }
  262.  
  263.     getchar();
  264.  
  265.     getchar(); system("Pause");
  266.  
  267. }
  268. int main()
  269. {
  270.     int wybor;
  271.     while (1)
  272.     {
  273.         system("cls");
  274.         menu();
  275.         cin >> wybor;
  276.         switch (wybor)
  277.         {
  278.             case 1:
  279.                 gra();
  280.             case 2:
  281.                 cout << "Patryk Sokolowski" << endl;
  282.                 cout << "Politechnika Bialostocka" << endl;
  283.                 cout << "kierunek: mechatronika";
  284.                 break;
  285.             case 3:
  286.                 exit(0);
  287.             default: cout << "Nie ma takiej opcji w menu!";
  288.         }
  289.         getchar(); getchar();
  290.         system("cls");
  291.     }
  292.  
  293.  
  294.  
  295.     logo();
  296.  
  297.     int punkty = 0;
  298.     int x = 3;
  299.  
  300.     int y = 3;
  301.  
  302.     int xp = 3; //x paletki
  303.  
  304.     int kxp = 1; //kierunek x paletki
  305.  
  306.     int kx = 1;
  307.  
  308.     int ky = 1;
  309.  
  310.     char aa;
  311.  
  312.     aa = 218; //z kodu asci
  313.  
  314.     gotoxy(1, 1); //lewy gorny naroznik
  315.  
  316.     cout << aa;
  317.  
  318.     aa = 192;
  319.  
  320.     gotoxy(1, 22); //prawy gorny naroznik
  321.  
  322.     cout << aa;
  323.  
  324.     aa = 217;
  325.  
  326.     gotoxy(70, 22); //prawy dolny naroznik
  327.  
  328.     cout << aa;
  329.  
  330.     aa = 191;
  331.  
  332.     gotoxy(70, 1); //lewy dolny naroznik
  333.  
  334.     cout << aa;
  335.  
  336.     aa = 196;
  337.  
  338.     //ramka 70x22
  339.  
  340.     for (int i = 2; i < 70; i++)
  341.  
  342.     {
  343.  
  344.         gotoxy(i, 1);
  345.  
  346.         cout << aa;
  347.  
  348.     }
  349.  
  350.     aa = 179;
  351.  
  352.     for (int i = 2; i < 22; i++)
  353.  
  354.     {
  355.  
  356.         gotoxy(1, i);
  357.  
  358.         cout << aa;
  359.  
  360.     }
  361.  
  362.     aa = 196;
  363.  
  364.     for (int i = 2; i < 70; i++)
  365.  
  366.     {
  367.  
  368.         gotoxy(i, 22);
  369.  
  370.         cout << aa;
  371.  
  372.     }
  373.  
  374.     aa = 179;
  375.  
  376.     for (int i = 2; i < 22; i++)
  377.  
  378.     {
  379.  
  380.         gotoxy(70, i);
  381.  
  382.         cout << aa;
  383.  
  384.     }
  385.  
  386.     char ee = 'q';
  387.  
  388.     while (ee == 'q')
  389.  
  390.     {
  391.  
  392.         gotoxy(x, y);
  393.  
  394.         cout << "o"; //piłeczka
  395.  
  396.         gotoxy(xp, 19); //kordy paletki
  397.  
  398.         aa = 196;
  399.  
  400.         cout << aa << aa << aa << aa << aa;
  401.  
  402.         Sleep(50);
  403.  
  404.         gotoxy(x, y);
  405.  
  406.         cout << " ";
  407.  
  408.         gotoxy(xp, 19);
  409.  
  410.         cout << "     ";
  411.  
  412.  
  413.  
  414.         //odbicie
  415.  
  416.         if ((xp > 64) || (xp < 3))
  417.  
  418.         {
  419.  
  420.             kxp = -1 * kxp;
  421.  
  422.         }
  423.  
  424.         xp = xp + kxp;
  425.  
  426.         if ((x > 67) || (x < 3))
  427.  
  428.         {
  429.  
  430.             kx = -1 * kx;
  431.  
  432.         }
  433.  
  434.         x = x + kx;
  435.  
  436.         if ((y > 20) || (y < 3))
  437.  
  438.         {
  439.  
  440.             ky = -1 * ky;
  441.  
  442.         }
  443.  
  444.         y = y + ky;
  445.  
  446.         if ((y == 19) && (x >= xp) && (x <= xp + 4))
  447.  
  448.         {
  449.  
  450.             ky = -1 * ky;
  451.             punkty = punkty + 1;
  452.         }
  453.  
  454.         char ch1;
  455.  
  456.         while (_kbhit())
  457.  
  458.         {
  459.  
  460.             ch1 = _getch();
  461.  
  462.             if (ch1 == 'e')
  463.  
  464.             {
  465.  
  466.                 ee = 'e';
  467.  
  468.             }
  469.  
  470.             if (ch1 == ' ')
  471.  
  472.             {
  473.  
  474.                 kxp = -1 * kxp;
  475.  
  476.             }
  477.  
  478.         }
  479.         pp(punkty);
  480.     }
  481.  
  482.     getchar();
  483.  
  484.     getchar(); system("Pause");
  485.  
  486.     return 0;
  487.  
  488. }
  489.  
  490. //animacja do loga
  491.  
  492. //zrobic menu
  493.  
  494. //zrobic punkty
  495.  
  496. //ZRobic logo z ascii ART (google)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement