Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. #include "TXlib.h"
  2.  
  3. void CircleDraw ();
  4. void CirclePhysics (int* x, int* y, int* VX, int* VY, int DT, double ax, double ay);
  5. void circleMove ( int* VX, int* VY, int WhatForDown, int WhatForUp, int WhatForLeft, int WhatForRight);
  6. void CircleDDDD(int x, int y);
  7. void CircleDDDD2(int x2, int y2);
  8.  
  9.  
  10. int main()
  11. {
  12. txCreateWindow (1020, 700);
  13.  
  14.  
  15. CircleDraw ();
  16.  
  17.  
  18.  
  19. return 0;
  20. }
  21.  
  22.  
  23.  
  24.  
  25. void CircleDraw ()
  26. {
  27. int x = 100, y = 100;
  28. int VX = 10, VY = 5;
  29. int DT = 1;
  30.  
  31.  
  32. int x2 = 600, y2 = 500;
  33. int VX2 = 10, VY2 = 5;
  34.  
  35. double ax = 0, ay = 0;
  36.  
  37. while (!GetAsyncKeyState(VK_ESCAPE))
  38. {
  39. txSetColor (RGB(255, 0, 0));
  40. CircleDDDD(x, y);
  41. CircleDDDD2(x2, y2);
  42.  
  43.  
  44.  
  45.  
  46. CirclePhysics (&x, &y, &VX, &VY, DT, ax, ay);
  47. circleMove ( &VX, &VY, VK_DOWN, VK_UP, VK_LEFT, VK_RIGHT);
  48.  
  49. CirclePhysics (&x2, &y2, &VX2, &VY2, DT, ax, ay);
  50. circleMove ( &VX2, &VY2, 'S', 'W', 'A', 'D');
  51.  
  52. txSleep (1);
  53. }
  54. }
  55.  
  56.  
  57.  
  58.  
  59. void CirclePhysics (int* x, int* y, int* VX, int* VY, int DT, double ax, double ay)
  60. {
  61. *x = *x + *VX * DT;
  62. *y = *y + *VY * DT;
  63.  
  64. *x = *x + ax*DT;
  65. *y = *y + ay*DT;
  66.  
  67. if (*x > 1020)
  68. {
  69. *VX = -(*VX);
  70. *x = 1020;
  71. txSetFillColor (RGB (rand(), rand(), rand()));
  72. }
  73.  
  74. if (*x < 0)
  75. {
  76. *VX = -(*VX);
  77. *x = 0;
  78. txSetFillColor (RGB (rand(), rand(), rand()));
  79. }
  80.  
  81. if (*y < 0)
  82. {
  83. *VY = -(*VY);
  84. *y = 0;
  85. txSetFillColor (RGB (rand(), rand(), rand()));
  86. }
  87.  
  88. if (*y > 700)
  89. {
  90. *VY = -(*VY);
  91. *y = 700;
  92. txSetFillColor (RGB (rand(), rand(), rand()));
  93. }
  94.  
  95.  
  96. txSleep (0);
  97.  
  98. }
  99.  
  100.  
  101.  
  102. void circleMove ( int* VX, int* VY, int WhatForDown, int WhatForUp, int WhatForLeft, int WhatForRight)
  103. {
  104. if (GetAsyncKeyState (WhatForUp))
  105. {
  106. (*VY)--;
  107. txSetFillColor (RGB (rand(), rand(), rand()));
  108. }
  109.  
  110. if (GetAsyncKeyState(WhatForDown))
  111. {
  112. (*VY)++;
  113. txSetFillColor (RGB (rand(), rand(), rand()));
  114. }
  115.  
  116. if (GetAsyncKeyState(WhatForLeft))
  117. {
  118. (*VX)--;
  119. txSetFillColor (RGB (rand(), rand(), rand()));
  120. }
  121.  
  122. if (GetAsyncKeyState(WhatForRight))
  123. {
  124. (*VX)++;
  125. txSetFillColor (RGB (rand(), rand(), rand()));
  126. }
  127.  
  128. }
  129.  
  130.  
  131. void CircleDDDD(int x, int y)
  132. {
  133. txCircle (x, y, 50);
  134.  
  135. }
  136.  
  137.  
  138. void CircleDDDD2(int x2, int y2)
  139. {
  140. txCircle (x2, y2, 50);
  141.  
  142. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement