C graphics circle movement

Closed
Geradwilly Posts 3 Registration date Monday May 15, 2017 Status Member Last seen May 15, 2017 - Updated on May 15, 2017 at 01:34 PM
Ambucias Posts 47356 Registration date Monday February 1, 2010 Status Moderator Last seen February 15, 2023 - May 15, 2017 at 04:45 PM
Hey guys I need help in C programming
Im trying to make program with a circle inside few tiny circle move from one end to other
I have created circle and tiny circles(particles) but they move in same order I want it as follows
1.> First particle moves , and when it returns the next moves and so on
2.> First particle moves while returning second moves same for third

pls refer the following code:

#include <stdio.h>
#include <conio.h>
#include <graphics.h>
#include <dos.h>

int main() {
int gd = DETECT, gm;
int i, x, y,x1,y1 ,flag=0;
initgraph(&gd, &gm, "C:\\TC\\BGI");

/* get mid positions in x and y-axis */
x = 180;//getmaxx()/2;
y = getmaxy()/2;
x1= getmaxx()/2;
y1=getmaxy()/2;

while (!kbhit()) {
setcolor(GREEN);
circle(x1-160,y1,150);
if(x >= getmaxx()-240 ||x <=175)
flag = !flag;
setcolor(BLUE);
setfillstyle(SOLID_FILL,BLUE);
circle(x-160,y,5);
floodfill(x-160,y,BLUE);
setcolor(RED);
setfillstyle(SOLID_FILL,RED);
circle(x-140,y+20,5);
floodfill(x-140,y+20,RED);
setcolor(YELLOW);
setfillstyle(SOLID_FILL,YELLOW);
circle(x-120,y-20,5);
floodfill(x-120,y-20,YELLOW);



/* delay for 50 milli seconds */
setcolor(10);

delay(10);

/* clears screen */
cleardevice();
if(flag){
x=x-1;

} else {

x=x+1;
}
}

getch();
closegraph();
return 0;
}

////

Ill repeat

I want
1.> Yellow to move to end of circle and come back then Red should move same to blue ....
2.> Yellow to move to end of circle then Red should move while yellow is coming back and once yellow is back Blue shud move

Hope I have made my point clear
Thank you for reading

1 response

Ambucias Posts 47356 Registration date Monday February 1, 2010 Status Moderator Last seen February 15, 2023 11,172
May 15, 2017 at 04:45 PM
Sorry but CCM does not provide help for homework assignments.
-1