#include<stdio.h>
#include<graphics.h>
#include<conio.h>
#include<dos.h>
#include<math.h>
void draw_clock()
{
int x=320,y=240,r=200,i,h,m,s,thetamin,thetasec;
char n[12][3]={"3","2","1","12","11","10","9","8","7","6","5","4"};
circle(x,y,210);
setcolor(4);
settextstyle(3,0,5);
for(i=0;i<12;i++)
outtextxy(x+(r-14)*cos(M_PI/6*i)-10,y-(r-14)*sin(M_PI/6*i)-20,n[i]);
}
void draw_time(int h,int m,int s,int theta,int thetamin,int thetasec)
{
int x=320,y=240,r=200,i;
int x1,y1;
int m1,s1,h1;
setcolor(RED);
setfillstyle(1,RED);
if(m>=15)
m1=m-15;
else
m1=m+45;
for(i=0;i<m1;i++)
thetamin+=6;
x1=x+(r-20)*cos(thetamin*M_PI/180);
y1=y+(r-20)*sin(thetamin*M_PI/180);
line(x,y,x1,y1);
setcolor(WHITE);
setfillstyle(1,WHITE);
if(s>=15)
s1=s-15;
else
s1=s+45;
for(i=0;i<s1;i++)
thetasec+=6;
x1=x+(r-10)*cos(thetasec*M_PI/180);
y1=y+(r-10)*sin(thetasec*M_PI/180);
line(x,y,x1,y1);
setcolor(CYAN);
setfillstyle(1,CYAN);
if(h>=3)
h1=h-3;
else
h1=h+9;
for(i=0;i<h1;i++)
theta+=30;
x1=x+(r-80)*cos(theta*M_PI/180);
y1=y+(r-80)*sin(theta*M_PI/180);
line(x,y,x1,y1);
if(!kbhit())
{
int x=320,y=240,r=200,i,j,k;
int t=60-s,n=60-m,flag=0,mflag=0;
for(i=0;i<12;i++)
{
if(mflag==1)
{
n=60;
thetamin=-90;
}
for(j=0;j<=n;j++)
{
if(flag==1)
{
t=60;
thetasec=-90;
}
for(k=0;k<=t;k++)
{
if((thetasec+(6*k))==270)
{
flag=1;
}
setcolor(BLACK);
line(x,y,x+(r-20)*cos((thetamin+(6*j)-6)*M_PI/180),y+(r-20)*sin((thetamin+(6*j)-6)*M_PI/180));
setcolor(RED);
line(x,y,x+(r-20)*cos((thetamin+(6*j))*M_PI/180),y+(r-20)*sin((thetamin+(6*j))*M_PI/180));
delay(100);
if((thetamin+(6*j))==270)
{
mflag=1;
setcolor(BLACK);
line(x,y,x+(r-80)*cos((theta+(6*i))*M_PI/180),y+(r-80)*sin((theta+(6*i))*M_PI/180));
setcolor(CYAN);
line(x,y,x+(r-80)*cos((theta+(6*i)+30)*M_PI/180),y+(r-80)*sin((theta+(6*i)+30)*M_PI/180));
delay(100);
}
setcolor(BLACK);
line(x,y,x+(r-10)*cos((thetasec+(6*k))*M_PI/180),y+(r-10)*sin((thetasec+(6*k))*M_PI/180));
setcolor(WHITE);
line(x,y,x+(r-10)*cos((thetasec+(6*k)+6)*M_PI/180),y+(r-10)*sin((thetasec+(6*k)+6)*M_PI/180));
delay(100);
}
}
}
}
}
int main()
{
int gd=DETECT,gm;
int h,m,s;
int theta=0,thetamin=0,thetasec=0;
printf("Enter the time:hour,min,secondsn");
scanf("%d%d%d",&h,&m,&s);
initgraph(&gd,&gm,"..//bgi");
draw_clock();
draw_time(h,m,s,theta,thetamin,thetasec);
getch();
return 1;
}
Tuesday, September 21, 2010
#include
#include
#include
#include
#include
void *bitmap;
void draw_car()
{
int size;
setcolor(RED);
line(0,300,getmaxx(),300);
circle(20,289,10);
circle(60,289,10);
rectangle(0,249,80,279);
rectangle(20,229,60,249);
size=imagesize(0,229,80,299);
bitmap=malloc(size);
getimage(0,229,80,289,bitmap);
}
void redraw(int x)
{
int flag=0;
while(1)
{
if(kbhit())
{
char ch=getch();
cleardevice();
if(ch=='a')
{
x+=2;
flag++;
line(0,300,getmaxx(),300);
}
if(ch=='d')
{
x-=2;
flag++;
}
if(ch=='r')
{
x=0;
}
if(ch=='h')
{
putimage(0+x,229,bitmap,COPY_PUT);
line(0,300,getmaxx(),300);
circle(20+x,289,10);
circle(60+x,289,10);
setfillstyle(1,BLUE);
pieslice(20+x,289,0,90,10);
pieslice(20+x,289,180,270,10);
pieslice(60+x,289,0,90,10);
pieslice(60+x,289,180,270,10);
sound(800);
delay(40);
nosound();
}
if(ch=='q')
break;
}
if(flag%2==0)
{
putimage(0+x,229,bitmap,COPY_PUT);
line(0,300,getmaxx(),300);
circle(20+x,289,10);
circle(60+x,289,10);
setfillstyle(1,BLUE);
pieslice(20+x,289,0,90,10);
pieslice(20+x,289,180,270,10);
pieslice(60+x,289,0,90,10);
pieslice(60+x,289,180,270,10);
}
else
{
putimage(0+x,229,bitmap,COPY_PUT);
line(0,300,getmaxx(),300);
circle(20+x,289,10);
circle(60+x,289,10);
pieslice(20+x,289,90,180,10);
pieslice(20+x,289,270,360,10);
pieslice(60+x,289,90,180,10);
pieslice(60+x,289,270,360,10);
}
delay(100);
if(x<=0)
x=0;
if(x==640)
x-=10;
}
}
int main()
{
int gd=DETECT,gm,x=0,choice;
void *bitmap;
initgraph(&gd,&gm,"..//bgi");
draw_car();
redraw(x);
return 1;
}
Subscribe to:
Posts (Atom)