📄 吃豆豆游戏.htm
字号:
putch(48+win);<BR>
else<BR>
{<BR>
putch(48+win/10);<BR>
gotoxy(61,8);<BR>
putch(48+win%10);<BR>
}<BR>
}<BR>}</P>
<P>/*+++++++++该数组用来正确的控制吃掉完所有的$后,才显示胜利+++++++++*/<BR>static
int win[21][32]={0};</P>
<P>/*++++++++++++++++++++++以下的四个函数为人走动的函数+++++++++++++++++++++*/<BR>void
MoveLeft()/*向左走*/<BR>{<BR> if(n>0&&map[m][n-1]!='#')<BR>
{<BR>
--n;<BR>
textcolor(BLACK);<BR>
gotoxy(x,y);<BR>
putch('
');<BR>
textcolor(YELLOW);<BR>
gotoxy(--x,y);<BR>
putch(1);<BR>
if(map[m][n]=='$'&&win[m][n]!=1)<BR>
{<BR>
win[m][n]=1;<BR>
Win(++bean);
/*判断是否胜利*/<BR>
}<BR>
for(i=0;i<BOYS;i++)<BR>
if(x==bx[i]&&y==by[i])<BR>
Lost();<BR>
}<BR>}</P>
<P>void
MoveRight()/*向右走*/<BR>{<BR> if(n<Map_x&&map[m][n+1]!='#')<BR>
{<BR>
++n;<BR>
textcolor(BLACK);<BR>
gotoxy(x,y);<BR>
putch('
');<BR>
textcolor(YELLOW);<BR>
gotoxy(++x,y);<BR>
putch(1);<BR>
if(map[m][n]=='$'&&win[m][n]!=1)<BR>
{<BR>
win[m][n]=1;<BR>
Win(++bean);<BR>
}<BR>
for(i=0;i<BOYS;i++)<BR>
if(x==bx[i]&&y==by[i])<BR>
Lost();<BR>
}<BR>}</P>
<P>void
MoveUp()/*向上走*/<BR>{<BR> if(m>0&&map[m-1][n]!='#')<BR>
{<BR>
--m;<BR>
textcolor(BLACK);<BR>
gotoxy(x,y);<BR>
putch('
');<BR>
textcolor(YELLOW);<BR>
gotoxy(x,--y);<BR>
putch(1);<BR>
if(map[m][n]=='$'&&win[m][n]!=1)<BR>
{<BR>
win[m][n]=1;<BR>
Win(++bean);<BR>
}<BR>
for(i=0;i<BOYS;i++)<BR>
if(x==bx[i]&&y==by[i])<BR>
Lost();<BR>
}<BR>}</P>
<P>void
MoveDown()/*向下走*/<BR>{<BR> if(m<Map_y&&map[m+1][n]!='#')<BR>
{<BR>
++m;<BR>
textcolor(BLACK);<BR>
gotoxy(x,y);<BR>
putch('
');<BR>
textcolor(YELLOW);<BR>
gotoxy(x,++y);<BR>
putch(1);<BR>
if(map[m][n]=='$'&&win[m][n]!=1)<BR>
{<BR>
win[m][n]=1;<BR>
Win(++bean);
/*判断是否胜利*/<BR>
}<BR>
for(i=0;i<BOYS;i++)<BR>
if(x==bx[i]&&y==by[i])<BR>
Lost();<BR>
}<BR>}</P>
<P>void
Lost()/*当人和badboy碰到时,就认为人被kill了*/<BR>{<BR> flag=0;<BR> move=NO;<BR> gotoxy(60,2);<BR> printf("You
Lost!");<BR>}</P>
<P>/*+++++++++++++++++++++++以下为badboy走动的函数+++++++++++++++++++++*/<BR>void
BadBoy(int num)<BR>{<BR> int
direct;<BR> randomize();<BR> direct=random(4)+1;<BR> switch(direct)<BR>
{<BR>
case
1:if(bm[num]>0&&map[bm[num]-1][bn[num>!='#'&&map[bm[num]-1][bn[num>!='$')/*向上走*/<BR>
{<BR>
for(i=0;i<BOYS;i++)<BR>
if(i!=num&&bm[num]-1==bm[i]&&bn[num]==bn[i])break;<BR>
--bm[num];<BR>
textcolor(BLACK);<BR>
gotoxy(bx[num],by[num]);<BR>
putch('
');<BR>
textcolor(BOYCOLOR);<BR>
gotoxy(bx[num],--by[num]);<BR>
putch(15);<BR>
}<BR>
if(bx[num]==x&&by[num]==y)<BR>
Lost();<BR>
break;<BR>
case
2:if(bn[num]>0&&map[bm[num>[bn[num]-1]!='#'&&map[bm[num>[bn[num]-1]!='$')
/*向左走*/<BR>
{<BR>
for(i=0;i<BOYS;i++)<BR>
if(i!=num&&bm[num]==bm[i]&&bn[num]-1==bn[i])break;<BR>
--bn[num];<BR>
textcolor(BLACK);<BR>
gotoxy(bx[num],by[num]);<BR>
putch('
');<BR>
textcolor(BOYCOLOR);<BR>
gotoxy(--bx[num],by[num]);<BR>
putch(15);<BR>
}<BR>
if(bx[num]==x&&by[num]==y)<BR>
Lost();<BR>
break;<BR>
case
3:if(bn[num]<Map_x&&map[bm[num>[bn[num]+1]!='#'&&map[bm[num>[bn[num]+1]!='$')/*向右走*/<BR>
{<BR>
for(i=0;i<BOYS;i++)<BR>
if(i!=num&&bm[num]==bm[i]&&bn[num]+1==bn[i])break;<BR>
++bn[num];<BR>
textcolor(BLACK);<BR>
gotoxy(bx[num],by[num]);<BR>
putch('
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -