Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "TXlib.h"
- void CircleDraw ();
- void CirclePhysics (int* x, int* y, int* VX, int* VY, int DT, double ax, double ay);
- void circleMove ( int* VX, int* VY, int WhatForDown, int WhatForUp, int WhatForLeft, int WhatForRight);
- void CircleDDDD(int x, int y);
- void CircleDDDD2(int x2, int y2);
- int main()
- {
- txCreateWindow (1020, 700);
- CircleDraw ();
- return 0;
- }
- void CircleDraw ()
- {
- int x = 100, y = 100;
- int VX = 10, VY = 5;
- int DT = 1;
- int x2 = 600, y2 = 500;
- int VX2 = 10, VY2 = 5;
- double ax = 0, ay = 0;
- while (!GetAsyncKeyState(VK_ESCAPE))
- {
- txSetColor (RGB(255, 0, 0));
- CircleDDDD(x, y);
- CircleDDDD2(x2, y2);
- CirclePhysics (&x, &y, &VX, &VY, DT, ax, ay);
- circleMove ( &VX, &VY, VK_DOWN, VK_UP, VK_LEFT, VK_RIGHT);
- CirclePhysics (&x2, &y2, &VX2, &VY2, DT, ax, ay);
- circleMove ( &VX2, &VY2, 'S', 'W', 'A', 'D');
- txSleep (1);
- }
- }
- void CirclePhysics (int* x, int* y, int* VX, int* VY, int DT, double ax, double ay)
- {
- *x = *x + *VX * DT;
- *y = *y + *VY * DT;
- *x = *x + ax*DT;
- *y = *y + ay*DT;
- if (*x > 1020)
- {
- *VX = -(*VX);
- *x = 1020;
- txSetFillColor (RGB (rand(), rand(), rand()));
- }
- if (*x < 0)
- {
- *VX = -(*VX);
- *x = 0;
- txSetFillColor (RGB (rand(), rand(), rand()));
- }
- if (*y < 0)
- {
- *VY = -(*VY);
- *y = 0;
- txSetFillColor (RGB (rand(), rand(), rand()));
- }
- if (*y > 700)
- {
- *VY = -(*VY);
- *y = 700;
- txSetFillColor (RGB (rand(), rand(), rand()));
- }
- txSleep (0);
- }
- void circleMove ( int* VX, int* VY, int WhatForDown, int WhatForUp, int WhatForLeft, int WhatForRight)
- {
- if (GetAsyncKeyState (WhatForUp))
- {
- (*VY)--;
- txSetFillColor (RGB (rand(), rand(), rand()));
- }
- if (GetAsyncKeyState(WhatForDown))
- {
- (*VY)++;
- txSetFillColor (RGB (rand(), rand(), rand()));
- }
- if (GetAsyncKeyState(WhatForLeft))
- {
- (*VX)--;
- txSetFillColor (RGB (rand(), rand(), rand()));
- }
- if (GetAsyncKeyState(WhatForRight))
- {
- (*VX)++;
- txSetFillColor (RGB (rand(), rand(), rand()));
- }
- }
- void CircleDDDD(int x, int y)
- {
- txCircle (x, y, 50);
- }
- void CircleDDDD2(int x2, int y2)
- {
- txCircle (x2, y2, 50);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement