Report

C graphics circle movement [Closed]

Ask a question Geradwilly 3Posts Monday May 15, 2017Registration date May 15, 2017 Last seen - Last answered on May 15, 2017 at 04:45 PM by Ambucias
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
See more 
Helpful
-1
plus moins
Sorry but CCM does not provide help for homework assignments.

Member requests are more likely to be responded to.

Members can monitor the statuses of their requests from their account pages.

A CCM membership gives you access to additional options.

Not a member yet?

Sign up now. It takes less than a minute and is completely free!