How to make a circle move on a straight line?

Hey, I have written the following code:

#include <graphics.h>

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

main()
{
int i, j = 0, gd = DETECT, gm;

initgraph(&gd,&gm,“C:\TC\BGI”);

settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
outtextxy(25,240,“Press any key to view the moving circle”);

getch();
setviewport(0,0,639,440,1);

for( i = 0 ; i <= 420 ; i = i + 10, j++ )
{
circle(50+i,410,10);
delay(100);

  if( i == 420 )
 break;

  clearviewport();

}

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

Now, I need help on how can I make it move or roll on a straight line.
Secondly, how can I insert a spoke into it.

If u want to move the circle, move the center ahead, and redraw the circle, with the new center.
If u want to create the effect of a roll, you will have to add spokes to realize the effect of rolling.
Try first by drawing only 1 spoke across the diameter.
use this relation: if a circle moves ahead by a distance of 2 x pi x r the spoke will be rotated by 360 degrees

2 Likes

is it a home work?