Rotation of a Wheel

Write a program to implement rotation of a wheel.


#include<conio.h>
#include<stdio.h>
#include<graphics.h>
#include<math.h>
void wheel1(int x,int y)
{
	int r=20;
	circle(x,y,r);
	line(x,y-r,x,y+r);
	line(x-r,y,x+r,y);
}
void wheel2(int x,int y)
{
	int r=20,fac;
	fac=r*(sin((45*M_PI)/180));
	circle(x,y,r);
	line(x+fac,y+fac,x-fac,y-fac);
	line(x-fac,y+fac,x+fac,y-fac);

}
void main()
{
	int gd=DETECT,gm,x=100,y=380;
	int c=0;
	initgraph(&gd,&gm,"c:\\tc\\bgi");
	while(!kbhit())
	{
		cleardevice();
		c++;
		line(0,400,639,400);
		if(c%2==0)
			wheel1(x,y);
		else
			wheel2(x,y);
		x=(x+10)%639;
		delay(200);
	}
	getch();
}


Output
1

Leave a Reply

Your email address will not be published. Required fields are marked *