Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <windows.h>
- #include <process.h>
- using namespace std;
- int pion = 20;
- int pion_byl;
- int pod = 0;
- int poziom = 0;
- int poziom_byl;
- string c_pies1 = "() () /\n";
- string c_pies2 = "(^.^)......./ \n";
- string c_pies3 = " || || \n";
- void rysuj_psa()
- {
- pion_byl = pion;
- system("cls");
- cout << "''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''";
- for (int i = 0; i < pion; i++)
- {
- cout << endl;
- }
- cout << c_pies1;
- cout << c_pies2;
- cout << c_pies3;
- for (int i = 0; i < pod; i++)
- {
- cout << endl;
- }
- cout << "'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''";
- }
- void __cdecl dupa( void * Args )
- {
- for (;;)
- {
- char a;
- a = getch();
- if ((a == 'w')||(a == 'W'))
- {
- if (pion > 1)
- {
- Sleep(250);
- pion-=3;
- pod+=3;
- }
- }
- if ((a == 'a')||(a == 'A'))
- {
- if (poziom > 0)
- {
- Sleep(250);
- poziom-=3;
- c_pies1.erase(0,3);
- c_pies2.erase(0,3);
- c_pies3.erase(0,3);
- }
- }
- if ((a == 'd')||(a == 'D'))
- {
- if (poziom < 63)
- {
- Sleep(250);
- poziom_byl = poziom;
- poziom+=3;
- c_pies1 = " " + c_pies1;
- c_pies2 = " " + c_pies2;
- c_pies3 = " " + c_pies3;
- }
- }
- }
- _endthread();
- }
- void __cdecl lap_zmiany( void * Args )
- {
- for (;;)
- {
- if (pion > 19)
- {
- pion = 20;
- pod = 0;
- }
- if ((pion_byl != pion)||(poziom_byl != poziom))
- {
- rysuj_psa();
- poziom_byl = poziom;
- }
- Sleep(10);
- }
- _endthread();
- }
- int main()
- {
- cout << "Sterowanie: " << endl;
- cout << "W = GORA" << endl;
- cout << "A = LEWO" << endl;
- cout << "D = PRAWO" << endl;
- Sleep(2500);
- HANDLE hThread =(HANDLE) _beginthread(dupa, 0, NULL );
- HANDLE hThread1 =(HANDLE) _beginthread(lap_zmiany, 0, NULL );
- for(;;)
- {
- pion++;
- pod--;
- Sleep(200);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment