Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. #include"TXLib.h"
  2.  
  3. //{Prototipy
  4. void DrawCircle(int x, int y);
  5. void DrawRectangle(int x, int y);
  6. void MoveTelo(int* x, int* y, int* vx , int* vy, int dt);
  7. void PartIgra();
  8. void Vol2();
  9. void MoveTasic(int* x, int* vx, int dt);
  10.  
  11.  
  12. //}
  13.  
  14. int main()
  15.  
  16.  
  17. {
  18. txCreateWindow (1500, 900);
  19. txSetFillColor(RGB(255, 255, 255));
  20. //HDC Ogon = txLoadImage ("Resources\\Images\\Background.bmp");
  21. txClear();
  22. PartIgra();
  23. Vol2();
  24.  
  25. }
  26.  
  27. void DrawCircle(int x , int y)
  28.  
  29. {
  30. txSetFillColor(RGB(255, 174, 201));
  31. txSetColor(TX_NULL);
  32. txCircle(x, y, 30);
  33. }
  34.  
  35. void DrawRectangle(int x, int y)
  36.  
  37. {
  38. txSetFillColor(RGB(0, 162, 201));
  39. txSetColor(TX_NULL);
  40. txRectangle(x, y, x + 200, y + 40);
  41. }
  42.  
  43. void MoveTelo(int* x, int* y, int* vx , int* vy, int dt)
  44.  
  45. {
  46. *x = *x + *vx*dt;
  47. *y = *y + *vy*dt;
  48.  
  49. if (*x > 1500)
  50.  
  51. {
  52. *vx = -*vx;
  53. *x = 1500;
  54. };
  55.  
  56.  
  57. if (*y > 900)
  58.  
  59. {
  60. *vy = -*vy;
  61. *y = 900;
  62. };
  63.  
  64. if (*y < 0)
  65.  
  66. {
  67. *vy = -*vy;
  68. *y = 0;
  69. };
  70.  
  71. if (*x < 0)
  72.  
  73. {
  74. *vx = -*vx;
  75. *x = 0;
  76. };
  77.  
  78. }
  79.  
  80. void PartIgra()
  81.  
  82. {
  83. int x = 750, y = 450, vx = 7, vy = 3;
  84. int x1 = 650, vx1 = 4, y1 = 820;
  85. int dt = 2, dt2 = 6;
  86.  
  87. while ( !GetAsyncKeyState (VK_ESCAPE))
  88.  
  89. {
  90. txSetFillColor(RGB(255, 255, 255));
  91. //txTransparentBlt (txDC(), 0, 0, 1500, 900, Ogon, 0, 0);
  92. txClear();
  93. DrawCircle(x , y);
  94. DrawRectangle(x1, 820);
  95.  
  96. MoveTelo(&x, &y, &vx, &vy, dt);
  97. MoveTasic(&x1, &vx1, dt2);
  98.  
  99. if ((y1 - y) < 20)
  100.  
  101. {
  102. vy = -vy;
  103. x = x1;
  104. }
  105.  
  106.  
  107. txSleep(1);
  108. };
  109.  
  110. }
  111.  
  112. void Vol2()
  113.  
  114. {
  115. int t = 0;
  116. while (t <= 900)
  117.  
  118. {
  119. DrawRectangle(650 + t*1, 820);
  120. }
  121. if ( GetAsyncKeyState (VK_LEFT))
  122. {
  123. t++;
  124. };
  125.  
  126. txSleep(10);
  127.  
  128.  
  129. }
  130.  
  131.  
  132. void MoveTasic(int* x, int* vx, int dt)
  133.  
  134. {
  135. *x = *x + *vx*dt;
  136.  
  137. if (*x > 1500)
  138.  
  139. {
  140. *vx = -*vx;
  141. *x = 1500;
  142. };
  143.  
  144.  
  145. if (*x < 0)
  146.  
  147. {
  148. *vx = -*vx;
  149. *x = 0;
  150. };
  151.  
  152. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement