# include "graphics.h"
# include "stdlib.h"
# define ESC 0x11b
struct ball
{
int color;
int xx;
int yy;
}balls[5]; /*定义气球*/
struct gun
{int flag;
int color;
int xx;
int yy;
int ff;
}guns[5]; /*定义子弹*/
char des[10]={104,0,101,0,108,0,108,0,111,0}; /*初始气球上的字母*/
int flag[5]={1,1,1,1,1};
long gun_a=0,gun_b=0; /*统计子弹数目*/
int depth[5]={5,5,5,5,5}; /*标记*/
void *buffer_ball[5],*buffer_gun[5]; /*定义图形存储指针*/
unsigned size;
char c[32]={0x08,0x00,0x0C,0x00,
0x1B,0xFE,0x10,0x08,
0x30,0x08,0x27,0xC8,
0x64,0x48,0xA4,0x48, /*何__字模*/
0x24,0x48,0x27,0xC8,
0x24,0x48,0x20,0x08,
0x20,0x08,0x20,0x28,
0x20,0x10,0x00,0x00
};
char y[32]={0x00,0x00,0x7C,0x3C,
0x45,0xE0,0x44,0x20,
0x44,0x20,0x7C,0x20,
0x13,0xFE,0x10,0x20, /*跃__字模*/
0x5C,0x50,0x50,0x50,
0x50,0x88,0x50,0x88,
0x5D,0x04,0xE1,0x06,
0x02,0x04,0x04,0x00
};
void Init() /*初始函数*/
{
int gdriver=DETECT,gmode,ii;
registerbgidriver(EGAVGA_driver);
initgraph(&gdriver,&gmode,"");
randomize();
for(ii=0;ii<5;ii++)
{
balls[ii].color=random(6)+1;
balls[ii].xx=84+90*ii;
balls[ii].yy=48;
guns[ii].ff=0;
}
}
void Draw_name(char *c,int x,int y) /*汉字输出*/
{
char mask[8]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
int i,j,k;
for(k=0;k<16;k++)
{
for(i=0;i<2;i++)
for(j=0;j<8;j++)
{if((c[k*2+i]&mask[j])!=0) putpixel(x,y,YELLOW);
x++;
}
y++;
x=590;
}
}
void Draw_m() /*画界面*/
{
int ii,jj;
setfillstyle(SOLID_FILL,11);
for(ii=0;ii<32;ii++)
{bar(25+15*ii,396,38+15*ii,409);
bar(25+15*ii,20,38+15*ii,33);
}
for(ii=0;ii<24;ii++)
{bar(25,35+15*ii,38,48+15*ii);
bar(490,35+15*ii,503,48+15*ii);
}
for(jj=0;jj<5;jj++)
{setfillstyle(SOLID_FILL,jj+5);
for(ii=0;ii<15;ii++)
bar(40+30*ii,320+15*jj,68+30*ii,333+15*jj);
}
settextstyle(0,0,1);
Draw_name(c,590,300);
Draw_name(y,590,330);
setcolor(RED);
outtextxy(530,400,"2005_12_15");
setcolor(14);
outtextxy(20,440,"Press 'ENTER' to start the game,then you can press 'ESC' to quit it");
settextstyle(0,0,4);
setcolor(12);
outtextxy(530,50,"K");
outtextxy(530,90,"E");
outtextxy(530,130,"Y");
setcolor(GREEN);
outtextxy(540,170,"B");
outtextxy(540,210,"O");
outtextxy(540,250,"A");
outtextxy(540,290,"R");
outtextxy(540,330,"D");
}
Draw_ball() /*画气球*/
{int ii;
settextstyle(0,0,2);
for(ii=0;ii<5;ii++)
{setcolor(balls[ii].color);
circle(balls[ii].xx,balls[ii].yy,12);
setfillstyle(SOLID_FILL,balls[ii].color);
floodfill(balls[ii].xx,balls[ii].yy,balls[ii].color);
setcolor(YELLOW);
outtextxy(balls[ii].xx-7,balls[ii].yy-7,&des[ii*2]);
}
size=imagesize(balls[0].xx-12,balls[0].yy-12,balls[0].xx+12,balls[0].yy+12);
for(ii=0;ii<5;ii++)
{buffer_ball[ii]=malloc(size);
getimage(balls[ii].xx-12,balls[ii].yy-12,balls[ii].xx+12,balls[ii].yy+12,buffer_ball[ii]);
}
}
void Draw_gun(int ii) /*画子弹*/
{
setcolor(guns[ii].color);
setlinestyle(0,0,3);
line(guns[ii].xx,guns[ii].yy,guns[ii].xx,guns[ii].yy+20);
line(guns[ii].xx,guns[ii].yy,guns[ii].xx-10,guns[ii].yy+5);
# include "stdlib.h"
# define ESC 0x11b
struct ball
{
int color;
int xx;
int yy;
}balls[5]; /*定义气球*/
struct gun
{int flag;
int color;
int xx;
int yy;
int ff;
}guns[5]; /*定义子弹*/
char des[10]={104,0,101,0,108,0,108,0,111,0}; /*初始气球上的字母*/
int flag[5]={1,1,1,1,1};
long gun_a=0,gun_b=0; /*统计子弹数目*/
int depth[5]={5,5,5,5,5}; /*标记*/
void *buffer_ball[5],*buffer_gun[5]; /*定义图形存储指针*/
unsigned size;
char c[32]={0x08,0x00,0x0C,0x00,
0x1B,0xFE,0x10,0x08,
0x30,0x08,0x27,0xC8,
0x64,0x48,0xA4,0x48, /*何__字模*/
0x24,0x48,0x27,0xC8,
0x24,0x48,0x20,0x08,
0x20,0x08,0x20,0x28,
0x20,0x10,0x00,0x00
};
char y[32]={0x00,0x00,0x7C,0x3C,
0x45,0xE0,0x44,0x20,
0x44,0x20,0x7C,0x20,
0x13,0xFE,0x10,0x20, /*跃__字模*/
0x5C,0x50,0x50,0x50,
0x50,0x88,0x50,0x88,
0x5D,0x04,0xE1,0x06,
0x02,0x04,0x04,0x00
};
void Init() /*初始函数*/
{
int gdriver=DETECT,gmode,ii;
registerbgidriver(EGAVGA_driver);
initgraph(&gdriver,&gmode,"");
randomize();
for(ii=0;ii<5;ii++)
{
balls[ii].color=random(6)+1;
balls[ii].xx=84+90*ii;
balls[ii].yy=48;
guns[ii].ff=0;
}
}
void Draw_name(char *c,int x,int y) /*汉字输出*/
{
char mask[8]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
int i,j,k;
for(k=0;k<16;k++)
{
for(i=0;i<2;i++)
for(j=0;j<8;j++)
{if((c[k*2+i]&mask[j])!=0) putpixel(x,y,YELLOW);
x++;
}
y++;
x=590;
}
}
void Draw_m() /*画界面*/
{
int ii,jj;
setfillstyle(SOLID_FILL,11);
for(ii=0;ii<32;ii++)
{bar(25+15*ii,396,38+15*ii,409);
bar(25+15*ii,20,38+15*ii,33);
}
for(ii=0;ii<24;ii++)
{bar(25,35+15*ii,38,48+15*ii);
bar(490,35+15*ii,503,48+15*ii);
}
for(jj=0;jj<5;jj++)
{setfillstyle(SOLID_FILL,jj+5);
for(ii=0;ii<15;ii++)
bar(40+30*ii,320+15*jj,68+30*ii,333+15*jj);
}
settextstyle(0,0,1);
Draw_name(c,590,300);
Draw_name(y,590,330);
setcolor(RED);
outtextxy(530,400,"2005_12_15");
setcolor(14);
outtextxy(20,440,"Press 'ENTER' to start the game,then you can press 'ESC' to quit it");
settextstyle(0,0,4);
setcolor(12);
outtextxy(530,50,"K");
outtextxy(530,90,"E");
outtextxy(530,130,"Y");
setcolor(GREEN);
outtextxy(540,170,"B");
outtextxy(540,210,"O");
outtextxy(540,250,"A");
outtextxy(540,290,"R");
outtextxy(540,330,"D");
}
Draw_ball() /*画气球*/
{int ii;
settextstyle(0,0,2);
for(ii=0;ii<5;ii++)
{setcolor(balls[ii].color);
circle(balls[ii].xx,balls[ii].yy,12);
setfillstyle(SOLID_FILL,balls[ii].color);
floodfill(balls[ii].xx,balls[ii].yy,balls[ii].color);
setcolor(YELLOW);
outtextxy(balls[ii].xx-7,balls[ii].yy-7,&des[ii*2]);
}
size=imagesize(balls[0].xx-12,balls[0].yy-12,balls[0].xx+12,balls[0].yy+12);
for(ii=0;ii<5;ii++)
{buffer_ball[ii]=malloc(size);
getimage(balls[ii].xx-12,balls[ii].yy-12,balls[ii].xx+12,balls[ii].yy+12,buffer_ball[ii]);
}
}
void Draw_gun(int ii) /*画子弹*/
{
setcolor(guns[ii].color);
setlinestyle(0,0,3);
line(guns[ii].xx,guns[ii].yy,guns[ii].xx,guns[ii].yy+20);
line(guns[ii].xx,guns[ii].yy,guns[ii].xx-10,guns[ii].yy+5);