Pulley

Write a program to animate the movement of the pulley.


#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
	int gd=DETECT,gm,x=320,y=100,d=0,dy=40,dyr=429-y;
	initgraph(&gd,&gm,"c:\\tc\\bgi");
	while(!kbhit())
	{
		cleardevice();
		circle(x,y,40);
		pieslice(x,y,0+d,20+d,40);
		pieslice(x,y,120+d,140+d,40);
		pieslice(x,y,240+d,260+d,40);
		d=(d+10)%100;
		line(x-40,y,x-40,y+dy);
		rectangle(x-70,y+dy,x-10,y+dy+50);
		dy+=10;

		line(x+40,y,x+40,y+dyr);
		rectangle(x+10,y+dyr,x+70,y+dyr+20);
		dyr-=10;
		line(10,451,620,451);
		if(y+dy+50>=451)
			break;
		if(y+dyr+20<=y+60)
			break;
		delay(100);
	}
	getch();
}


Output
1

Leave a Reply

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