Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include"TXLib.h"
- //{Prototipy
- void DrawCircle(int x, int y);
- void DrawRectangle(int x, int y);
- void MoveTelo(int* x, int* y, int* vx , int* vy, int dt);
- void PartIgra();
- void Vol2();
- void MoveTasic(int* x, int* vx, int dt);
- //}
- int main()
- {
- txCreateWindow (1500, 900);
- txSetFillColor(RGB(255, 255, 255));
- //HDC Ogon = txLoadImage ("Resources\\Images\\Background.bmp");
- txClear();
- PartIgra();
- Vol2();
- }
- void DrawCircle(int x , int y)
- {
- txSetFillColor(RGB(255, 174, 201));
- txSetColor(TX_NULL);
- txCircle(x, y, 30);
- }
- void DrawRectangle(int x, int y)
- {
- txSetFillColor(RGB(0, 162, 201));
- txSetColor(TX_NULL);
- txRectangle(x, y, x + 200, y + 40);
- }
- void MoveTelo(int* x, int* y, int* vx , int* vy, int dt)
- {
- *x = *x + *vx*dt;
- *y = *y + *vy*dt;
- if (*x > 1500)
- {
- *vx = -*vx;
- *x = 1500;
- };
- if (*y > 900)
- {
- *vy = -*vy;
- *y = 900;
- };
- if (*y < 0)
- {
- *vy = -*vy;
- *y = 0;
- };
- if (*x < 0)
- {
- *vx = -*vx;
- *x = 0;
- };
- }
- void PartIgra()
- {
- int x = 750, y = 450, vx = 7, vy = 3;
- int x1 = 650, vx1 = 4, y1 = 820;
- int dt = 2, dt2 = 6;
- while ( !GetAsyncKeyState (VK_ESCAPE))
- {
- txSetFillColor(RGB(255, 255, 255));
- //txTransparentBlt (txDC(), 0, 0, 1500, 900, Ogon, 0, 0);
- txClear();
- DrawCircle(x , y);
- DrawRectangle(x1, 820);
- MoveTelo(&x, &y, &vx, &vy, dt);
- MoveTasic(&x1, &vx1, dt2);
- if ((y1 - y) < 20)
- {
- vy = -vy;
- x = x1;
- }
- txSleep(1);
- };
- }
- void Vol2()
- {
- int t = 0;
- while (t <= 900)
- {
- DrawRectangle(650 + t*1, 820);
- }
- if ( GetAsyncKeyState (VK_LEFT))
- {
- t++;
- };
- txSleep(10);
- }
- void MoveTasic(int* x, int* vx, int dt)
- {
- *x = *x + *vx*dt;
- if (*x > 1500)
- {
- *vx = -*vx;
- *x = 1500;
- };
- if (*x < 0)
- {
- *vx = -*vx;
- *x = 0;
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement