|
楼主 |
发表于 2007-5-25 18:40:50
|
显示全部楼层
O O O O",
" O OOO O O OOO O",
" O OO O OO",
" O O O O O O",
"O OOOOOO O OOOOOO"
};
int Name_X = 26;
int Name_Y = 8;
void DrawBegin()
{
int x, y;
for (y=0; y<Name_Y; ++y)
{
for(x=0; x<Name_X; ++x)
{
gotoxy(x+21, y+5);
textcolor(LIGHTBLUE);
putch(name[y][x]);
}
}
gotoxy(19, 20);
printf("Press any key to Enter the game!");
}
/*游戏地图,#为墙壁,@为箱子,试着自己改改*/
char map1[8][17] =
{"#################",
"# @@@@ @ #@# ##",
"# #@#@#@ @@@ #",
"# @@@ @@ #@#@##",
"#@#@#@#@ @@@@@@#",
"#@@@@@ @@#@#@##",
"#@#@#@#@@ @@@@@#",
"#################"};
int Map_X = 17;
int Map_Y = 8;
char map[8][17];
void DrawMap()
{
int x, y;
for (y=0; y<Map_Y; ++y)
{
for(x=0; x<Map_X; ++x)
{
gotoxy(x+15, y+6);
if(map[y][x] == '#')
{
textcolor(GREEN);
putch(219);
}
else if(map[y][x] == '@')
{
textcolor(BROWN);
putch(178);
}
else
putch(' ');
}
}
textcolor(BLUE);
gotoxy(48, 4);
printf("Player1 key:");
gotoxy(48, 5);
printf(" UP----w");
gotoxy(48, 6);
printf(" DOWN--s");
gotoxy(48, 7);
printf(" LEFT--a");
gotoxy(48, 8);
printf(" RIGHT-d");
gotoxy(48, 9);
printf(" FIRE--space");
gotoxy(48, 11);
printf("Player2 key:");
gotoxy(48, 12);
printf(" UP----up");
gotoxy(48, 13);
printf(" DOWN--down");
gotoxy(48, 14);
printf(" LEFT--left");
gotoxy(48, 15);
printf(" RIGHT-right");
gotoxy(48, 16);
printf(" FIRE--ENTER");
gotoxy(48, 18);
printf("exit game:");
gotoxy(48, 19);
printf(" ESC");
gotoxy(38, 2);
textcolor(LIGHTRED);
putch('P');
putch('A');
putch('O');
putch('P');
putch('A');
putch('O');
}
/*炸箱子后,出宝物的函数*/
Treasure(int x, int y)
{
int i;
i = random(15);
if (i > 10)
{
switch (i)
{
case 11:
case 12:
map[y][x] = 'O';
gotoxy(x+15, y+6);
textcolor(YELLOW);
putch('o');
break;
case 13:
case 14:
map[y][x] = '-';
gotoxy(x+15, y+6);
textcolor(YELLOW);
putch(18);
break;
default:
break;
}
}
else
{
map[y][x] = ' ';
gotoxy(x+15, y+6);
putch(' ');
}
}
/*人物m向上移动的函数*/
int MoveUp(man *m, man *p)
{
if (map[m->y - 1][m->x] == '#' || map[m->y - 1][m->x] == '@'
|| map[m->y - 1][m->x] == 'o' || m->can_move == CANNOT)
{
return 1;
}
EraseMan(*m);
if (map[m->y][m->x] == 'o')
{
DrawPao(m->x, m->y);
}
--(m->y);
DrawMan(*m);
switch (map[m->y][m->x])
{
case 'a':
case 'b':
m->can_move = CANNOT;
m->old_time = clock();
break;
case 'O':
++(m->pao_num);
map[m->y][m->x] = ' ';
break;
case '-':
++(m->len);
map[m->y][m->x] = ' ';
break;
default:
break;
}
if (m->x == p->x && m->y == p->y && p->can_move == CANNOT)
{
gotoxy(36, 3);
printf("Play%d Win!!", m->which);
return 0;
}
return 1;
}
/*人物m向下移动的函数*/
int MoveDown(man *m, man *p)
{
if (map[m->y + 1][m->x] == '#' || map[m->y + 1][m->x] == '@'
|| map[m->y + 1][m->x] == 'o' || m->can_move == CANNOT)
{
return 1;
}
EraseMan(*m);
if (map[m->y][m->x] == 'o')
{
DrawPao(m->x, m->y);
}
++(m->y);
DrawMan(*m);
switch (map[m->y][m->x])
{
case 'a':
case 'b':
m->can_move = CANNOT;
m->old_time = clock();
break;
case 'O':
++(m->pao_num); |
|