荔园在线
荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀
[回到开始]
[上一篇][下一篇]
发信人: lvyou (天下无双孤星泪), 信区: Program
标 题: 趣味TC2程序《青蛙游太空》
发信站: BBS 荔园晨风站 (Sun Mar 11 21:13:36 2001), 转信
# ifdef TINY__
#endif
#include<dos.h>
#include<math.h>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include<stdarg.h>
#include<graphics.h>
#define ESC 0x1b
#define TRUE 1
#define FALSE 0
#define PI 3.14159
#define ON 1
#define OFF 0
char *Fonts[]={"DefaultFont","TriplexFont","SmallFont","SansSerifFont",
"GothicFont"};
char *LineStyles[]={"EmptyFill","SolidFill","BkSlashFill",
"LtBkSlashFill",
"HatchFill","HatchFill","XHatchFill","InterleaveFill",
"WideDotFill","CloseDotFill"
};
char *TextDirect[]={"HorizDir","VertDir"};
char *HorizJust[]={"LeftText","CenterText","RightText"};
char *VertJust[]={"BottomText","CenterText","TopText"};
struct PTS{int x,y;};
int GraphDriver;
int GraphMode;
double AspectRatio;
int MaxX,MaxY;
int MaxColors;
int ErrorCode;
struct palettetype palette;
void Initialize(void);
void PutImageDemo(void);
void changetextstyle(int font,int direction,int charsize);
int gprintf(int *xloc,int *yloc,char *fmt,...);
int main()
{
Initialize();
PutImageDemo();
closegraph();
return(0);
}
void Initialize(void)
{
int xasp,yasp;
GraphDriver=DETECT;
initgraph(&GraphDriver,&GraphMode,"");
ErrorCode=graphresult();
if (ErrorCode!=0)
{
printf("Graphics System Error:%s\n",grapherrormsg(ErrorCode));
exit(1);}
getpalette(&palette);
MaxColors=getmaxcolor()+1;
MaxX=getmaxx();
MaxY=getmaxy();
getaspectratio(&xasp,&yasp);
AspectRatio=(double)xasp/(double)yasp;
}
void PutImageDemo(void)
{
static int r=20;
static int StartX=100;
static int StartY=50;
struct viewporttype vp;
int PauseTime,x,y,ulx,uly,lrx,lry,size,i,width,height,step;
void *Saucer;
getviewsettings(&vp);
setfillstyle(SOLID_FILL,getmaxcolor());
fillellipse(StartX,StartY,r,(r/3)+2);
ellipse(StartX,StartY-4,190,357,r,r/3);
line(StartX+7,StartY-6,StartX+10,StartY-12);
circle(StartX+10,StartY-12,2);
line(StartX-7,StartY-6,StartX-10,StartY-12);
circle(StartX-10,StartY-12,2);
ulx=StartX-(r+1);
uly=StartY-14;
lrx=StartX+(r+1);
lry=StartY+(r/3)+3;
width=lrx-ulx+1;
height=lry-uly+1;
size=imagesize(ulx,uly,lrx,lry);
Saucer=malloc(size);
getimage(ulx,uly,lrx,lry,Saucer);
putimage(ulx,uly,Saucer,XOR_PUT);
for (i=0;i<600;++i)
putpixel(random(MaxX),random(MaxY),random(MaxColors-1)+1);
x=MaxX/2;
y=MaxY/2;
PauseTime=10000;
while (!kbhit())
{
putimage(x,y,Saucer,XOR_PUT);
delay(PauseTime);
putimage(x,y,Saucer,XOR_PUT);
step=random(2*r);
if ((step/2)%2!=0)
step=-1*step;
x=x+step;
step=random(r);
if ((step/2)%2!=0)
step=-1*step;
y=y+step;
if (vp.left+x+width-1>vp.right)
x=vp.right-vp.left-width+1;
else if (x<0)
x=0;
if (vp.top+y+height-1>vp.bottom)
y=vp.bottom-vp.top-height+1;
else if (y<0)
y=0;
}
free(Saucer);
getch();
}
--
^^
,+ '`^`''+,
.' '.
/ \
^^-_-^^-_-^^-_-^^-_-^^-_-^^-_-^^^^-_-^^-_-^^-_-^^-_-^^-_-^^-_-^^^^-_-^^-_- ^^-?
※ 来源:·BBS 荔园晨风站 bbs.szu.edu.cn·[FROM: 192.168.28.29]
[回到开始]
[上一篇][下一篇]
荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店