在迷宫中找出几个数之和是7的数并把它们吃掉后再吃掉7就获胜了。(编得简单了点,但这是我编的第一个游戏请多指教)
#define UP 0x4800
#define DOWN 0x5000
#define LEFT 0x4b00
#define RIGHT 0x4d00
#include "conio.h"
#include "time.h"
#include "stdlib.h"
int k[17][24]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,1,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,
0,1,1,1,1,1,1,0,0,0,0,0,0,1,0,0,0,0,0,1,1,1,0,0,
0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,
0,3,1,1,1,1,0,1,1,1,1,1,0,1,0,1,1,1,1,1,1,1,0,0,
0,1,0,0,1,0,1,0,0,0,0,1,0,1,1,1,0,0,0,0,0,0,0,0,
0,1,1,1,1,1,6,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,
0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,1,1,1,1,0,
0,1,1,1,1,1,1,1,1,1,1,5,1,1,1,0,1,0,0,1,0,0,0,0,
0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,4,0,0,1,0,0,0,0,
0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,1,1,0,1,1,0,
0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,0,
0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,
0,0,1,1,1,1,0,0,0,0,0,0,0,1,1,1,3,1,1,1,1,1,0,0,
0,2,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,
0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,};
main()
{int i,j,key,num;
aa: clrscr();
num=0;
textcolor(GREEN);
gotoxy(14,1);
cprintf("%c(UP) %c(DOWN) %c(LEFT) %c(RIGHT) ESC(QUIT)\n",24,25,27,26);
textcolor(RED);
for(i=4;i<21;i++)
for(j=20;j<44;j++)
if(k[i-4][j-20]==0)
{gotoxy(j,i);
cprintf("%c",219);
}
else if(k[i-4][j-20]!=1)
{gotoxy(j,i);
cprintf("%d",k[i-4][j-20]);
}
textcolor(YELLOW);
i=5;
j=21;
gotoxy(j,i);
cprintf("\1");
gotoxy(33,5);
cprintf("7");
do
{key=bioskey(0);
sound(200);
delay(1000);
nosound();
switch(key)
{case DOWN:{if(k[i-4+1][j-20]==0)continue;
if(k[i-4+1][j-20]!=1)num+=k[i-4+1][j-20];
textcolor(YELLOW);
gotoxy(j,i++);
printf(" ");
gotoxy(j,i);
cprintf("\1");gotoxy(33,5);
if(k[i-4][j-20]==7&&num==14)
{clrscr();printf("yes\n");exit(0);}
else if(num!=7&&k[i-4][j-20]==7){clrscr();printf("%d\n",num);delay(1000);goto aa;}
break; }
case UP:{if(k[i-4-1][j-20]==0)continue;
if(k[i-4-1][j-20]!=1)num+=k[i-4-1][j-20];
textcolor(YELLOW);
gotoxy(j,i--);
printf(" ");
gotoxy(j,i);
cprintf("\1");gotoxy(33,5);
if(k[i-4][j-20]==7&&num==14)
{clrscr();printf("yes\n");exit(0);}
else if(num!=7&&k[i-4][j-20]==7){clrscr();printf("%d\n",num);delay(100000);goto aa;}
break; }
case LEFT:{if(k[i-4][j-20-1]==0)continue;
if(k[i-4][j-20-1]!=1)num+=k[i-4][j-20-1];
textcolor(YELLOW);
gotoxy(j--,i);
printf(" ");
gotoxy(j,i);
cprintf("\1");gotoxy(33,5);
if(k[i-4][j-20]==7&&num==14)
{clrscr();printf("yes\n");exit(0);}
else if(num!=7&&k[i-4][j-20]==7){clrscr();printf("%d\n",num);delay(1000);goto aa;}
break; }
case RIGHT:{if(k[i-4][j-20+1]==0)continue;
if(k[i-4][j-20+1]!=1)num+=k[i-4][j-20+1];
textcolor(YELLOW);
gotoxy(j++,i);
printf(" ");
gotoxy(j,i);
cprintf("\1");gotoxy(33,5);
if(k[i-4][j-20]==7&&num==14)
{clrscr();printf("yes\n");exit(0);}
else if(num!=7&&k[i-4][j-20]==7){clrscr();printf("%d\n",num);delay(1000);goto aa;}
break; }
default :exit(0);
}
}while(1);
}
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |