Glenpl

Untitled

Oct 22nd, 2014
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <windows.h>
  4. #include <process.h>
  5.  
  6. using namespace std;
  7.  
  8. int pion = 20;
  9. int pion_byl;
  10. int pod = 0;
  11. int poziom = 0;
  12. int poziom_byl;
  13. string c_pies1 = "() ()        /\n";
  14. string c_pies2 = "(^.^)......./ \n";
  15. string c_pies3 = "     ||  ||   \n";
  16.  
  17. void rysuj_psa()
  18. {
  19.     pion_byl = pion;
  20.     system("cls");
  21.     cout << "''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''";
  22.     for (int i = 0; i < pion; i++)
  23.     {
  24.         cout << endl;
  25.     }
  26.  
  27.     cout << c_pies1;
  28.     cout << c_pies2;
  29.     cout << c_pies3;
  30.  
  31.     for (int i = 0; i < pod; i++)
  32.     {
  33.         cout << endl;
  34.     }
  35.     cout << "'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''";
  36. }
  37.  
  38. void __cdecl dupa( void * Args )
  39. {
  40.     for (;;)
  41.     {
  42.         char a;
  43.         a = getch();
  44.         if ((a == 'w')||(a == 'W'))
  45.         {
  46.             if (pion > 1)
  47.             {
  48.                 Sleep(250);
  49.                 pion-=3;
  50.                 pod+=3;
  51.             }
  52.         }
  53.         if ((a == 'a')||(a == 'A'))
  54.         {
  55.             if (poziom > 0)
  56.             {
  57.                 Sleep(250);
  58.                 poziom-=3;
  59.                 c_pies1.erase(0,3);
  60.                 c_pies2.erase(0,3);
  61.                 c_pies3.erase(0,3);
  62.             }
  63.         }
  64.         if ((a == 'd')||(a == 'D'))
  65.         {
  66.             if (poziom < 63)
  67.             {
  68.                 Sleep(250);
  69.                 poziom_byl = poziom;
  70.                 poziom+=3;
  71.                 c_pies1 = "   " + c_pies1;
  72.                 c_pies2 = "   " + c_pies2;
  73.                 c_pies3 = "   " + c_pies3;
  74.             }
  75.         }
  76.     }
  77.     _endthread();
  78. }
  79.  
  80. void __cdecl lap_zmiany( void * Args )
  81. {
  82.     for (;;)
  83.     {
  84.         if (pion > 19)
  85.         {
  86.             pion = 20;
  87.             pod = 0;
  88.         }
  89.         if ((pion_byl != pion)||(poziom_byl != poziom))
  90.         {
  91.             rysuj_psa();
  92.             poziom_byl = poziom;
  93.         }
  94.         Sleep(10);
  95.     }
  96.  
  97.     _endthread();
  98. }
  99.  
  100. int main()
  101. {
  102.     cout << "Sterowanie: " << endl;
  103.     cout << "W = GORA" << endl;
  104.     cout << "A = LEWO" << endl;
  105.     cout << "D = PRAWO" << endl;
  106.     Sleep(2500);
  107.  
  108.     HANDLE hThread =(HANDLE) _beginthread(dupa, 0, NULL );
  109.     HANDLE hThread1 =(HANDLE) _beginthread(lap_zmiany, 0, NULL );
  110.  
  111.     for(;;)
  112.     {
  113.         pion++;
  114.         pod--;
  115.         Sleep(200);
  116.     }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment