#include
#include
#include
#include
#define PI 3.14159265359
#define PLANETS_COUNT 9
void draw_planet(int cx, int cy, int x, int y, float angle, int fg, int bg);
int main(void) {
float x[PLANETS_COUNT], y[PLANETS_COUNT], angle[PLANETS_COUNT], step[PLANETS_COUNT];
int planets; char buf[80];
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "");
errorcode = graphresult();
if(errorcode != grOk) return -1;
for(planets=0; planets if(planets > 0) { x[planets] = x[planets-1]+15; y[planets]=y[planets-1]+15; }
else { x[planets] = 40; y[planets]=40; }
}
for(planets=0; planets { angle[planets] = rand() % 50; step[planets] = 1 + rand() %4; }
setcolor(WHITE);
setfillstyle(SOLID_FILL, YELLOW);
circle(350, 240, 20);
floodfill(352, 242, WHITE);
while(!kbhit())
{
for(planets=0; planetsdraw_planet(350, 240, x[planets], y[planets], angle[planets], BLACK, BLACK);
angle[planets] += step[planets];
if(angle[planets] >= 359) angle[planets] = 0;
draw_planet(350, 240, x[planets], y[planets], angle[planets], WHITE, BLUE);
sprintf(buf, "%d %f", planets, angle[planets]);
outtextxy(10, 10+(planets*15),buf);
}}
getch(); closegraph();
return 0;}
void draw_planet(int cx, int cy, int x, int y, float angle, int fg, int bg) {
float nx, ny;
nx = (x * cos(angle*(PI/180))) - (y * sin(angle*(PI/180)));
ny = (x * cos(angle*(PI/180))) + (y * sin(angle*(PI/180)));
setcolor(fg);
circle(cx + nx, cy + ny, 5);
setfillstyle(SOLID_FILL, bg);
floodfill(cx+2+nx, cy+2+ny, fg);}
Вот так анимация мерцает, что делать?: