移动的小车

作者在 2009-07-10 18:30:55 发布以下内容
#include"graphics.h"
#include"math.h"
#define PI 3.14
void main()
{
    int x1=50,y1=60,x2=120,y2=100,a=0;
    void  *buf;
    int size,i,n=1;
    int gdriver=DETECT,gmode;
    initgraph(&gdriver,&gmode," ");

    setbkcolor(BLUE);
    setcolor(YELLOW);

    rectangle(x1,y1,x2,y2);
    circle(x1+10,y2+5,8);
    circle(x2-10,y2+5,8);
    circle(x1+10,y2+5,5);
    circle(x2-10,y2+5,5);
    pieslice(x1+10,y2+5,a,a+30,8);
    pieslice(x2-10,y2+5,a,a+30,8);



    size=imagesize(x1,y1,x2,y2+20);
    buf=(void *)malloc(size);
    getimage(x1,y1,x2,y2+20,buf);
    cleardevice();
    putimage(x1,y1,buf,XOR_PUT);
      
    delay(500);
   
   while(!kbhit())
   {
     for(i=0;i<=500;i++)
     {
    putimage(x1+i+1,60,buf,COPY_PUT);
    cleardevice();
     }

   for(i=500;i>=0;i--)
     {
       putimage(x1+i-1,60,buf,COPY_PUT);
       cleardevice();
     }

   for(i=0;i<=500;i++)
    if(n%2==0)
    {
      a+=1;
    }
    else
           a-=1;
}
          n++;
    closegraph();
}
我参与过的话题 | 阅读 4606 次
文章评论,共0条
游客请输入验证码

DMS
浏览22291次
文章归档