程序开始会播放一段警报声音,该声音是机箱的报警喇叭发出来的。然后就是发射火箭的动画,最后是一个自己设计的菜单,和背景画面。发射火箭的动画不是我自己写的,是从一本书上看到的,然后自己改动后放在这的,作者要是看到请和我联系。这个可是提前预示着我们国家的“神一"到以后的"神……”的成功发射!此程序运行还需要c语言的图形库文件如下:BGIOBJ.EXE、CGA.BGI、EGAVGA.BGI、GOTH.CHR、HERC.BGI、IBM8514.BGI、LITT.CHR、PC3270.BGI、SANS.CHR、TRIP.CHR。
#include <graphics.h>
#include<process.h>
#include<stdlib.h>
#include<dos.h>
#include<conio.h>
#include <alloc.h>
#include<stdio.h>
#include <time.h>
#include<string.h>
#include<bios.h>
#include<ctype.h>
#define pi 3.1415926
#define X1(a,b,c) x=a*cos(b*c*pi/180-pi/2)+300;
#define Y(a,b,c) y=a*sin(b*c*pi/180-pi/2)+240;
#define d(a,b,c) X1(a,b,c);Y(a,b,c);line(300,240,x,y)
#define down 80
#define esc 1
#define ALT_F 33
#define ALT_X 45
#define up 72
#define home 71
#define end 79
#define enter 28
#define right 77
#define left 75
#define E 18
#define I 23
#define J 36
#define P 25
#define R 19
#define T 20
#define L 38
#define Z 44
#define S 31
#define f1 59
#define C 46
#define D 32
#define H 35
#define O 24
#define Q 16
#define X 45
#define FALSE 0
#define TRUE 1
#define Delay 1000000
#define RATE 100
#define IMAGE_SIZE 10
typedef struct rowcol
{int col,row;
}PRC;
void sufang(void);
void MessageBox(char *);
void DrawGun(void);
void DrawPlan(void);
void *buf;
PRC prc;
int x0=300;
int y0=340;
int width1=5;
int width2=20;
int height=25;
int copy=0;
int y1=8;
int y2=15;
int y3=23;
int y4=38;
int col;
int row;
void siren(void);
int getkey();
void choice_channel();
get_item(int,int,int);
void Putstar(void);
void *buf_curse;
void copt(void);
void times(void);
void diqiou(void);
void huojian(void);
void About(void);
main()
{
int driver=VGA,mode=VGAHI;
int ad[640];
int item_num,result,i,ch,flag,y,n,data,done,k;
float da,t;
unsigned size;
initgraph(&driver,&mode," ");
setbkcolor(BLACK);
cleardevice();
setcolor(14);
settextstyle(TRIPLEX_FONT,0,4);
settextjustify(1,1);
outtextxy(320,100,"Alarm is Ring !!!!");
outtextxy(320,150,"Please Be Careful !!!!");
settextjustify(0,0);
Putstar();
siren();
huojian();
MENU:initgraph(&driver,&mode," ");
size=imagesize(0,0,90,22);
if (size!=1)buf_curse=malloc(size);
setfillstyle(1,3);
bar(0,0,90,22);
getimage(0,0,90,22,buf_curse);
setfillstyle(1,0);
bar(0,0,91,23);
setcolor(14);
setviewport(0,0,639,479,1);
diqiou();
rectangle(0,0,639,479);
rectangle(0,457,639,479);
setfillstyle(1,7);
bar(1,458,638,478);
setcolor(0);
outtextxy(10,470,"F1_Help ALT_X-Quit");
setcolor(4);
outtextxy(10,470,"F1 ALT_X ");
if(copy==1)
copt();
setfillstyle(1,1);
rectangle(542,20,635,89);
bar(543,21,634,88);
rectangle(5,20,98,89);
bar(6,21,97,88);
item_num=4;
setcolor(14);
for (k=0;k<item_num;k++)
{
setfillstyle(1,0);
rectangle(542,90+k*25,635,115+k*25);
floodfill(544,92+k*25,14);
}
for(k=0;k<4;k++)
{
setfillstyle(1,0);
rectangle(452,90+k*25,542,115+k*25);
floodfill(452,92+k*25,14);
}
setcolor(14);
for (k=0;k<item_num;k++)
{
setfillstyle(1,0);
rectangle(5,90+k*25,98,115+k*25);
floodfill(7,92+k*25,14);
}
for(k=0;k<4;k++)
{
setfillstyle(1,0);
rectangle(98,90+k*25,191,115+k*25);
floodfill(99,92+k*25,14);
}
settextstyle(1,0,4);
outtextxy(548,40,"MENU");
outtextxy(11,40,"MENU");
settextstyle(0,0,1);
setcolor(14);
outtextxy(548,100,"Display");
outtextxy(548,125,"Copyright");
outtextxy(548,150,"Os shell");
outtextxy(548,175,"Quit");
outtextxy(11,100,"tIme");
outtextxy(11,125,"Copyright");
outtextxy(11,150,"Os shell");
outtextxy(11,175,"Quit");
outtextxy(104,100,"Shunxu");
outtextxy(104,125,"Lianshi");
outtextxy(104,150,"Roqueue");
outtextxy(104,175,"Zifuchuan");
outtextxy(458,100,"Jvzhen");
outtextxy(458,125,"Erchashu");
outtextxy(458,150,"Paixushu");
outtextxy(458,175,"Tu");
setcolor(13);
outtextxy(548,100,"D");
outtextxy(548,125,"C");
outtextxy(548,150,"O");
outtextxy(548,175,"Q");
outtextxy(19,100,"I");
outtextxy(11,125,"C");
outtextxy(11,150,"O");
outtextxy(11,175,"Q");
setcolor(13);
outtextxy(458,100,"J");
outtextxy(458,125,"E");
outtextxy(458,150,"P");
outtextxy(458,175,"T");
outtextxy(104,100,"S");
outtextxy(104,125,"L");
outtextxy(104,150,"R");
outtextxy(104,175,"Z");
setcolor(YELLOW);
settextstyle(TRIPLEX_FONT,0,4);
settextjustify(1,1);
outtextxy(320,400,"AROUND THE WORLD");
settextstyle(0,0,1);
settextjustify(0,0);
putimage(543,91,buf_curse,XOR_PUT);
setcolor(15);
row=0;
col=0;
done=FALSE;
do
{
get_item(row,col,item_num);
printf("%d",prc.col);
switch(prc.col)
{case 3:
switch(prc.row)
{
case 0:
cleardevice();
result = spawnl(P_WAIT,"d://tc//out//cc.exe", NULL);
if (result == -1){exit(1);}
goto MENU;
default:;}
case 0:
switch(prc.row)
{
case 0:
About();
goto MENU;
case 1:
putimage(543,91+prc.row*25,buf_curse,XOR_PUT);
prc.row=0;
putimage(543,91+prc.row*25,buf_curse,XOR_PUT);
copy=1;
goto MENU;
case 2:
free(buf_curse);
done=TRUE;
restorecrtmode();
system("");
goto MENU;
case 3:
done=TRUE;
closegraph();
exit(0);
} break;
case 1:
switch(prc.row)
{
case 0:
cleardevice();
result = spawnl(P_WAIT,"d://tp//sparmat.exe", NULL);
if (result == -1){exit(1);}
delay(500000);
break;
case 1:
cleardevice();
result = spawnl(P_WAIT,"d://tp//shu.exe", NULL);
if (result == -1){exit(1);}
delay(500000);
break;
case 2:
cleardevice();
result = spawnl(P_WAIT,"d://tp//paixu.exe", NULL);
if (result == -1){exit(1);}
delay(500000);
break;
case 3:
cleardevice();
result = spawnl(P_WAIT,"d://tp//tu.exe", NULL);
if (result == -1){exit(1);}
delay(500000);
break;
}
goto MENU;
case 2:
switch(prc.row)
{case 0:
cleardevice();
result = spawnl(P_WAIT,"d://tp//shunxu.exe", NULL);
if (result == -1){exit(1);}
delay(500000);
break;
case 1:
cleardevice();
result = spawnl(P_WAIT,"d://tp//lianshi.exe", NULL);
if (result == -1){exit(1);}
delay(500000);
break;
case 2:
cleardevice();
result = spawnl(P_WAIT,"d://tp//duilie.exe", NULL);
if (result == -1){exit(1);}
delay(500000);
break;
case 3:
cleardevice();
result = spawnl(P_WAIT,"d://tp//chuan.exe", NULL);
if (result == -1){exit(1);}
delay(500000);
break;
}
goto MENU;
}
}while(!done);
free(buf_curse);
restorecrtmode();
}
void choice_channel()
{
int result;
again:
rectangle(0,457,639,479);
setfillstyle(1,7);
bar(1,458,638,478);
setcolor(0);
outtextxy(10,470,"F1_Help ALT_X-Quit");
setcolor(4);
outtextxy(10,470,"F1 ALT_X ");
setfillstyle(1,1);
result = spawnl(P_WAIT,"d://tc//out//chuangti.exe", NULL);
if (result == -1){exit(1);}
}
get_item(int row,int col,int item_num)
{ int key,done,x,x1,x2,y1,y2,a,b;
PRC *rc=&prc;
rc->row=row;
rc->col=col;
done=FALSE;
do
{
key=get_key();
switch(key)
{case down:
switch(rc->col)
{case 0: x=543; break;
case 1: x=453; break;
case 2: x=99; break;
case 3:x=6; break;
}
putimage(x,91+rc->row*25,buf_curse,XOR_PUT);
if (rc->row==item_num-1)rc->row=0;
else rc->row+=1;
putimage(x,91+rc->row*25,buf_curse,XOR_PUT);
break;
case up:
switch(rc->col)
{case 0:x=543;break;
case 1: x=453; break;
case 2: x=99; break;
case 3:x=6; break;
}
putimage(x,91+rc->row*25,buf_curse,XOR_PUT);
if(rc->row==0)rc->row=item_num-1;
else rc->row-=1;
putimage(x,91+rc->row*25,buf_curse,XOR_PUT);
break;
case right:
switch(rc->col)
{
case 0: x1=543;x2=6;a=3;break;
case 1: x1=453;x2=543;a=0;break;
case 2: x1=99;x2=453;a=1;break;
case 3: x1=6;x2=99;a=2;break; }
if(rc->col!=a)
{
putimage(x1,91+rc->row*25,buf_curse,XOR_PUT);
rc->col=a;
putimage(x2,91+rc->row*25,buf_curse,XOR_PUT);
}
break;
case left:
switch(rc->col)
{
case 0: y1=543;y2=453;b=1; break;
case 1: y1=453;y2=99;b=2;break;
case 2: y1=99;y2=6;b=3;break;
case 3: y1=6;y2=543;b=3;break;
}
if(rc->col!=b)
{
putimage(y1,91+rc->row*25,buf_curse,XOR_PUT);
rc->col=b;
putimage(y2,91+rc->row*25,buf_curse,XOR_PUT);
}
break;
case X:
rc->row=item_num-1;
rc->col=0;
done=TRUE;
break;
case I:
rc->row=0;
rc->col=3;
done=TRUE;
break;
case S:
rc->row=0;
rc->col=2;
done=TRUE;
break;
case L:
rc->row=1;
rc->col=2;
done=TRUE;
break;
case R:
rc->row=2;
rc->col=2;
done=TRUE;
break;
case Z:
rc->row=3;
rc->col=2;
done=TRUE;
break;
case J:
rc->row=0;
rc->col=1;
done=TRUE;
break;
case E:
rc->row=1;
rc->col=1;
done=TRUE;
break;
case P:
rc->row=2;
rc->col=1;
done=TRUE;
break;
case T:
rc->row=3;
rc->col=1;
done=TRUE;
break;
case enter:
done=TRUE;
break;
case f1:
/*display help*/
MessageBox("The red word is hotkey!^*_*^");
break;
case home:
if(rc->row!=0)
{
putimage(543,91+rc->row*25,buf_curse,XOR_PUT);
rc->row=0;
putimage(543,91+rc->row*25,buf_curse,XOR_PUT);
}
break;
case end:
if(rc->row!=item_num-1)
{
putimage(543,91+rc->row*25,buf_curse,XOR_PUT);
rc->row=item_num-1;
putimage(543,91+rc->row*25,buf_curse,XOR_PUT);
}
break;
case D:
if(rc->row!=0)
{
putimage(543,91+rc->row*25,buf_curse,XOR_PUT);
rc->row=0;
putimage(543,91+rc->row*25,buf_curse,XOR_PUT);
}
done=TRUE;
break;
case C:
if(rc->row!=1)
{
putimage(543,91+rc->row*25,buf_curse,XOR_PUT);
rc->row=1;
putimage(543,91+rc->row*25,buf_curse,XOR_PUT);
}
copy=1;
done=TRUE;
break;
case O:
if(rc->row!=2)
{
putimage(543,91+rc->row*25,buf_curse,XOR_PUT);
rc->row=2;
putimage(543,91+rc->row*25,buf_curse,XOR_PUT);
}
done=TRUE;
break;
case Q:
if(rc->row!=3)
{
putimage(543,91+rc->row*25,buf_curse,XOR_PUT);
rc->row=3;
putimage(543,91+rc->row*25,buf_curse,XOR_PUT);
}
done=TRUE;
break;
default:
break;
}
} while(!done);
}
int get_key()
{
union REGS rg;
rg.h.ah=0;
int86(0x16,&rg,&rg);
return rg.h.ah;
}
void Putstar(void)
{
int seed=2000;
int i,dotx,doty,height,width,color,maxcolor;
maxcolor=getmaxcolor();
width=getmaxx();
height=getmaxy();
srand(seed);
for(i=0;i<250;i++){
dotx=i+random(width-1);
doty=i+random(height-1);
color=random(maxcolor);
setcolor(color);
putpixel(dotx,doty,color);
circle(dotx+1,doty+1,1);
}
srand(seed);
}
void copt(void)
{ int t;
setcolor(4);
line(582,461,582,475);
line(578,465,585,465);
line(577,468,586,468);
line(582,471,584,471);
line(580,470,577,476);
line(579,472,583,476);
line(583,476,593,476);
line(586,465,592,473);
line(592,465,587,473);
putpixel(610,462,4);
putpixel(611,463,4);
moveto(602,466);
linerel(1,-1);
linerel(0,-1);
linerel(15,0);
linerel(-2,2);
line(604,467,614,467);
line(604,471,614,471);
line(603,476,616,476);
line(612,473,613,474);
line(609,467,609,476);
}
void diqiou(void)
{
int maxx,maxy,midy,midx,i,key;
void *pt_addr;
unsigned int size;
maxx=getmaxx();
maxy=getmaxy();
midx=maxx/2;
midy=maxy/2;
setcolor(4);
setlinestyle(SOLID_LINE,0,NORM_WIDTH);
ellipse(midx,midy,130,50,160,30);
Putstar();
Putstar();
setcolor(5);
setlinestyle(SOLID_LINE,0,THICK_WIDTH);
ellipse(midx,midy,130,50,160,30);
setcolor(0);
ellipse(midx,midy,130,50,160,30);
for(i=0;i<=13;i++)
{
setcolor(i%2==0? LIGHTBLUE:0);
ellipse(midx,midy,0,360,100,100-8*i);
setcolor(LIGHTBLUE);
ellipse(midx,midy,0,360,100-8*i,100);
}
}
void siren (void)
{unsigned long i;
unsigned freq;
union{
long divisor;
unsigned char c[2];
}count;
unsigned char p;
p=inportb(97);
outportb(97,p|3);
for(freq=1000;freq<30000;freq+=RATE)
{
count.divisor=10000000/freq;
outportb(67,182);
outportb(66,count.c[0]);
outportb(66,count.c[1]);
for (i=0;i<Delay;++i);
if(kbhit()) exit(0);
}
for(;freq>1000;freq-=RATE)
{
count.divisor=10000000/freq;
outportb(67,182);
outportb(66,count.c[0]);
outportb(66,count.c[1]);
for (i=0;i<Delay;++i);
if (kbhit()) exit(0);
}
outportb(97,p);
}
void huojian (void)
{
int size;
int i=0;
int key1=0;
int station,result;
setbkcolor(BLACK);
cleardevice();
setcolor(BLUE);
settextstyle(TRIPLEX_FONT,0,4);
outtextxy(80,100,"Ready!...Any key to SET OFF !!!");
Putstar();
DrawGun();
getch();
cleardevice();
DrawGun();
DrawPlan();
Putstar();
setcolor(BLUE); /*define result words color*/
do{
putimage(x0-width2,y0-height-3*width1-i,buf,XOR_PUT);
i+=2;
putimage(x0-width2,y0-height-3*width1-i,buf,XOR_PUT);
delay(2000);
if(y0-height-3*width1-i==-2) {
outtextxy(60,100,"Successfully!!! Press anykey...... ");
key1+=1;}
else key1=0;
if(y0-height-3*width1-i==0) key1+=1;
}while(key1!=2);
getch();
getch();
free(buf);
}
void DrawGun(void)
{
int x0=300;
int y0=430;
int height=45;
int rx=20;
int ry=5;
int rightx,righty,leftx,lefty;
int centery1=30;
rightx=righty=leftx=lefty=12;
setcolor(LIGHTGREEN);
ellipse(x0,y0,180,360,rx,ry);
ellipse(x0,y0-height,0,360,rx,ry);
line(x0+rx,y0,x0+rx,y0-height);
line(x0-rx,y0,x0-rx,y0-height);
moveto(x0+rx,y0);
lineto(x0+rx+rightx,y0+righty);
moveto(x0+rx+rightx,y0+righty);
lineto(x0+rx+rightx+10,y0+righty+10);
circle(x0+rx+rightx+10,y0+righty+10,4);
moveto(x0,y0+ry);
lineto(x0,y0+centery1);
moveto(x0,y0+centery1);
lineto(x0,y0+centery1+10);
circle(x0,y0+centery1+10,4);
moveto(x0-rx,y0);
lineto(x0-rx-leftx,y0+lefty);
moveto(x0-rx-leftx,y0+lefty);
lineto(x0-rx-leftx-10,y0+lefty+10);
circle(x0-rx-leftx-10,y0+lefty+10,4);
line(x0-rx-leftx,y0+lefty,x0,y0+centery1);
line(x0,y0+centery1,x0+rx+rightx,y0+righty);
}
void DrawPlan(void)
{
int size;
setcolor(LIGHTRED);
setfillstyle(1,BLUE);
ellipse(x0,y0-height,0,180,width1,3*width1);
moveto(x0+width1,y0); /*moveto center right side*/
lineto(x0+width1,y0-height);
moveto(x0+width1,y0);
lineto(x0+width2,y0+y2);
moveto(x0-width1,y0); /*moveto center left side*/
lineto(x0-width1,y0-height);
moveto(x0-width1,y0);
lineto(x0-width2,y0+y2);
moveto(x0+width2,y0+y3);/*moveto right bottom side*/
lineto(x0+width2,y0+y1);
moveto(x0+width2,y0+y3);
lineto(x0+width1,y0+y2);
moveto(x0-width2,y0+y3);/*moveto left bottom side*/
lineto(x0-width2,y0+y1);
moveto(x0-width2,y0+y3);
lineto(x0-width1,y0+y2);
moveto(x0,y0+y4); /*moveto the bottomest*/
lineto(x0+width1,y0+y2);
moveto(x0,y0+y4);
lineto(x0-width1,y0+y2);
setfillstyle(2,LIGHTRED); /*fill the plan with a style */
floodfill(x0,y0,LIGHTRED);
size=imagesize(x0-width2-1,y0-height-3*width1,
x0+width2+1,y0+y4);
buf=malloc(size);
if(!buf){
printf("No enough memory!");
exit(0);
}
getimage(x0-width2,y0-height-3*width1,x0+width2,y0+y4,buf);
}
void About(void)
{int MidX,MidY,x1,y1,x2,y2,size;
void *buffer;
MidX=639/2;
MidY=160/2;
x1=MidX-100;x2=MidX+100;y1=MidY-50;y2=MidY+50;
size=imagesize(x1,y1,x2,y2);
if((buffer=malloc(size))==NULL)
{
outtextxy(100,100,"Out of memorry!Press any key to continue.");
getch();
}
else
{
getimage(x1,y1,x2,y2,buffer);
setfillstyle(SOLID_FILL,BLUE);
bar(x1,y1,x2-9,y2-9);
setfillstyle(SOLID_FILL,8);
bar(x1+8,y2-8,x2,y2);
bar(x2-8,y1+8,x2,y2);
setcolor(WHITE);
settextjustify(1,1);
outtextxy(MidX-4,MidY-40,"DATA STRUCTURE");
outtextxy(MidX-4,MidY-20,"DESIGN WITH TURBOC 2.0");
outtextxy(MidX-4,MidY+15,"1-2003 by Computer");
outtextxy(MidX-4,MidY+35,"Copyright@zhaobao");
rectangle(0,457,639,479);
setfillstyle(1,7);
bar(1,458,638,478);
setcolor(0);
outtextxy(10,470,"F1_Help ALT_X-Quit");
setcolor(4);
outtextxy(10,470,"F1 ALT_X ");
setfillstyle(1,1);
delay(500000);
getch();
putimage(x1,y1,buffer,COPY_PUT);
free(buffer);
settextjustify(LEFT_TEXT,TOP_TEXT);
}
delay(50000);
}
void MessageBox(char *Message)
{
int midx,midy,x1,y1,x2,y2,size,len;
void *buffer;
midx=320;
midy=46;
len=8*(strlen(Message)+1)/2;
x1=midx-len-5*8;
x2=midx+len+5*8;
y1=midy-40;
y2=midy+40;
size=imagesize(x1,y1,x2,y2);
if ((buffer=malloc(size))==NULL)
{
outtextxy(100,100,"Out of memorry! Press any key to continue.");
getch();
}
else
{
getimage(x1,y1,x2,y2,buffer);
setfillstyle(SOLID_FILL,6);
bar(x1,y1,x2-13,y2-13);
setfillstyle(SOLID_FILL,8);
bar(x1+12,y2-12,x2,y2);
bar(x2-12,y1+12,x2,y2);
setcolor(WHITE);
settextjustify(1,1);
outtextxy(midx,midy-20,Message);
setfillstyle(SOLID_FILL,LIGHTRED);
bar(midx-3*8,midy+6,midx+3*8,midy+24);
setcolor(YELLOW);
outtextxy(midx,midy+16,"OK");
getch();
putimage(x1,y1,buffer,COPY_PUT);
free(buffer);
settextjustify(LEFT_TEXT,TOP_TEXT);
}}