泡泡堂Word格式.docx
《泡泡堂Word格式.docx》由会员分享,可在线阅读,更多相关《泡泡堂Word格式.docx(39页珍藏版)》请在冰豆网上搜索。
![泡泡堂Word格式.docx](https://file1.bdocx.com/fileroot1/2022-11/16/9f197ee3-5334-4d77-adae-521399be768b/9f197ee3-5334-4d77-adae-521399be768b1.gif)
/*键盘中断函数(借用一个TC做的CS游戏中的)*/
#defineKEY_Y0x15
#defineKEY_N0x31
#defineKEY_A0x1E
#defineKEY_D0x20
#defineKEY_S0x1f
#defineKEY_W0x11
#defineKEY_ESC0x01
#defineKEY_ENTER0x1c
#defineKEY_SPACE0x39
#defineKEY_UP0x48
#defineKEY_LEFT0x4b
#defineKEY_RIGHT0x4d
#defineKEY_DOWN0x50
#definePLAY1UPKEY_W
#definePLAY1LEFTKEY_A
#definePLAY1DOWNKEY_S
#definePLAY1RIGHTKEY_D
#definePLAY1FIREKEY_SPACE
#definePLAY2UPKEY_UP
#definePLAY2DOWNKEY_DOWN
#definePLAY2LEFTKEY_LEFT
#definePLAY2RIGHTKEY_RIGHT
#definePLAY2FIREKEY_ENTER
voidInstallKeyboard(void);
voidShutDownKeyboard(void);
voidfarinterruptNewInt9(void);
intGetKey(intScanCode);
charkey_state[128],key_pressed[128];
voidinterruptfar(*OldInt9Handler)();
voidInstallKeyboard(void)/*键盘中断程序*/
{
inti;
for(i=0;
i<
128;
i++)
key_state[i]=key_pressed[i]=0;
OldInt9Handler=getvect(9);
/*中断向量值*/
setvect(9,NewInt9);
/*中断程序NewInt9地址存入指定的中断向量表中INT09H*/
}
voidShutDownKeyboard(void)
setvect(9,OldInt9Handler);
voidfarinterruptNewInt9(void)
unsignedcharScanCode,temp;
ScanCode=inportb(0x60);
temp=inportb(0x61);
outportb(0x61,temp|0x80);
outportb(0x61,temp&
0x7f);
if(ScanCode&
0x80)
{
ScanCode&
=0x7f;
key_state[ScanCode]=0;
}
else
key_state[ScanCode]=1;
key_pressed[ScanCode]=1;
outportb(0x20,0x20);
intGetKey(intScanCode)
intres;
res=key_state[ScanCode]|key_pressed[ScanCode];
key_pressed[ScanCode]=0;
returnres;
/*>
>
Manfunction--copyrightWonderfulandWangChengBo<
<
*/
typedefenum
PLAY1=1,PLAY2
}which_play;
CAN,
CANNOT
}MOVE;
typedefstruct
intx,y;
/*thepositionoftheman*/
which_playwhich;
/*play1orplay2?
MOVEcan_move;
/*canmanmove?
*/
intlen;
/*paopao'
slength*/
intpao_num;
/*howmanypaocanthemanfire?
intold_time;
/*人被泡泡炸后,恢复的时间*/
}man;
DrawMan(manm)
gotoxy(m.x+15,m.y+6);
if(m.which==PLAY1)
textcolor(YELLOW);
else
textcolor(LIGHTRED);
putch
(2);
DrawPaoMan(manm)
putch
(1);
EraseMan(manm)
textcolor(BLACK);
putch('
'
);
DrawPao(intx,inty)
gotoxy(x+15,y+6);
textcolor(LIGHTBLUE);
O'
DrawBlast1(intx,inty)
#'
charname[7][60]=
"
ooooooooooooo"
ooooooooooooo"
oooooooooooo"
oooooooooooooo"
oooooooooooooooo"
ooooooooo"
oooooooooooooooooo"
};
intName_X=60;
intName_Y=8;
voidDrawBegin()
for(y=0;
y<
Name_Y;
++y)
for(x=0;
x<
Name_X;
++x)
gotoxy(x+21,y+5);
putch(name[y][x]);
gotoxy(19,20);
printf("
PressanykeytoEnterthegame!
charmap1[8][17]=
{"
#################"
"
#@@@@@#@###"
##
#@@@@#"
#@@@@@#
##"
#
@@@@@@#"
#@@@@@@
#@##"
@@@@@@#"
intMap_X=17;
intMap_Y=8;
charmap[8][17];
voidDrawMap()
Map_Y;
Map_X;
if(map[y][x]=='
)
textcolor(GREEN);
putch(219);
elseif(map[y][x]=='
@'
textcolor(BROWN);
putch(178);
textcolor(BLUE);
gotoxy(48,4);
Player1key:
gotoxy(48,5);
UP----w"
gotoxy(48,6);
DOWN--s"
gotoxy(48,7);
LEFT--a"
gotoxy(48,8);
RIGHT-d"
gotoxy(48,9);
FIRE--space"
gotoxy(48,11);
Player2key:
gotoxy(48,12);
UP----up"
gotoxy(48,13);
DOWN--down"
gotoxy(48,14);
LEFT--left"
gotoxy(48,15);
RIGHT-right"
gotoxy(48,16);
FIRE--ENTER"
gotoxy(48,18);
exitgame:
gotoxy(48,19);
ESC"
gotoxy(38,2);
P'
A'
Treasure(intx,inty)
i=random(15);
if(i>
10)
switch(i)
case11:
case12:
map[y][x]='
;
o'
break;
case13:
case