这是课本上的源程序,但是编译总有问题:getimage函数参数看不太懂,还有EGAVGA_drive编译器总提示没申明,为什么?
#include"dos.h"
#include"math.h"
#include"conio.h"
#include"stdio.h"
#include"stdlib.h"
#include"stdarg.h"
#include<graphics.h>
void InitGra(void);
void SauFly(void);
void DrSaucer(int,int,int);
void DrStar();
int main()
{
InitGra();
SauFly();
Closegraph();
Return(0);
}
void SauFly(void)
{
int x,y,x1,y1,x2,y2,I,step,x0,y0,r;
void *Buf;
r=20;
x0=320;y0=200;
DrStar();
DrSaucer(x0,y0,r);
x1=x0-r-1;
y1=y0-14;
x2=x0+r+1;
y2=y0+r/3+3;
Buf=malloc(imagesize(x1,y1,x2,y2));
getimage(x1,y1,Buf,XOR_PUT);
putimage(x1,y1,Buf,XOR_PUT);
x=320;y=240;
while(!kbbhit())
{
putimage(x,y,Buf,XOR_PUT);
delay(80);
putimage(x,y,Buf,XOR_PUT);
step=random(2*r);
if((step/2)%2!=0)step=-1*step;
x+=step;
step=random(r);
if((step/2)!=2)step=-1*step;
y+=step;
if(y<0)y=0;
x+=step;
if(x<0)x=0;
}
free(Buf);
}
void InitGra()
{
int GraphMode,DraphDrive=DETECT;
registerbgidriver(EGAVGA_drive);
initgraph(&DraphDrive,&GraphMode," ");
}
void Drstar()
{
int i;
setbkcolor(1);
cleardevice();
for(i=0;8<1000;++i)
putpixel(random(639),random(479),random(15)+1);
}
void DrSaucer(int x0,int y0,int r)
{
setfillstyle(1,15);
fillellipse(x0,y0,r,(r/3)+2);
ellipse(x0,y0-4,1990,357,r,r/3);
line(x0+7,y0-6,x0+10,y0-12);
circle(x0+10,y0-12,2);
line(x0-7,y0-6,x0-10,y0-12);
circle(x0-10,y0-12,2);
}