菜鸟的找救老婆游戏
2008-03-08 12:42:17 来源:WEB开发网核心提示:前几天刚学了点东西,所以就乘热打铁编了个小游戏,希望大家多多指教,你只要可以走到下面的小人那里就可以了,可要快奥(不过我那个计时器根本没派上用处,只不过是看看而已的)#define WIN if(x==60&&y==20) break; /*胜利条件*/#define UP 0x4800#define DOWN 0x5
前几天刚学了点东西,所以就乘热打铁编了个小游戏,希望大家多多指教,你只要可以走到下面的小人那里就可以了,可要快奥(不过我那个计时器根本没派上用处,只不过是看看而已的)
#define WIN if(x==60&&y==20) break; /*胜利条件*/
#define UP 0x4800
#define DOWN 0x5000
#define LEFT 0x4b00
#define RIGHT 0x4d00
#include "conio.h"
#include "time.h"
main()
{int key,x,y,a,b,i,j,n=0;
int t;
clrscr();
textcolor(GREEN); /*图象初始化*/
gotoxy(22,1);
cPRintf("%c(UP) %c(DOWN) %c(LEFT) %c(RIGHT) ESC(QU99v)\n",24,25,27,26);
textcolor(RED);
for(i=20;i<=60;i++)
{
for(j=4;j<=18;j+=2)
{
gotoxy(i,j);
cprintf("%c",219);
}
gotoxy(i,21);
cprintf("%c",219);
}
for(i=4;i<=21;i++)
{
gotoxy(19,i);
cprintf("%c",219);
gotoxy(61,i);
cprintf("%c",219);
gotoxy(62,i);
cprintf("%c",219);
gotoxy(18,i);
cprintf("%c",219);
}
textcolor(YELLOW);
gotoxy(20,5);
cprintf("\1");
textcolor(12);
gotoxy(60,20);
cprintf("\2");
gotoxy(20,5);
x=20;
y=5;
textcolor(YELLOW);
t=0;
gotoxy(37,2);
cprintf("TIME:"); /*图象初始化结束*/
for(;;)
{
for(;!kbhit();) /*计时器*/
{
gotoxy(42,2);
if(t%500==0)
cprintf("%d",t/500);
t++;
delay(100);
} /*计时器结束*/
++n;
a=x;
b=y;
key=bioskey(0);
if(key==UP) /*判定按键*/
{
if(y==5)
continue;
gotoxy(x,--y);
WIN;
}
else if(key==DOWN)
{
if(y==20)
continue;
else if(y==5&&x!=60)
continue;
else if(y==7&&x!=50)
continue;
else if(y==9&&x!=40)
continue;
else if(y==11&&x!=30)
continue;
else if(y==13&&x!=20)
continue;
else if(y==15&&x!=25)
continue;
else if(y==17&&x!=55)
continue;
gotoxy(x,++y);
WIN;
}
else if(key==LEFT)
{
if(x==20)
continue;
gotoxy(--x,y);
WIN;
}
else if(key==RIGHT)
{
if(x==60)
continue;
gotoxy(++x,y);
WIN;
}
else if(key==0x11b)
exit(0);
else continue; /*判定结束*/
cprintf("\1"); /*输出图形*/
gotoxy(a,b);
printf(" ");
gotoxy(x,y);
sound(300); /*输出声音*/
delay(1000);
nosound();
}
clrscr(); /*输出结果*/
textcolor(12);
gotoxy(40,10);
cprintf("%c",2);
textcolor(RED);
gotoxy(22,11);
cprintf("After %d days, I will be your wife. %c",n,3);
getch();
}
#define UP 0x4800
#define DOWN 0x5000
#define LEFT 0x4b00
#define RIGHT 0x4d00
#include "conio.h"
#include "time.h"
main()
{int key,x,y,a,b,i,j,n=0;
int t;
clrscr();
textcolor(GREEN); /*图象初始化*/
gotoxy(22,1);
cPRintf("%c(UP) %c(DOWN) %c(LEFT) %c(RIGHT) ESC(QU99v)\n",24,25,27,26);
textcolor(RED);
for(i=20;i<=60;i++)
{
for(j=4;j<=18;j+=2)
{
gotoxy(i,j);
cprintf("%c",219);
}
gotoxy(i,21);
cprintf("%c",219);
}
for(i=4;i<=21;i++)
{
gotoxy(19,i);
cprintf("%c",219);
gotoxy(61,i);
cprintf("%c",219);
gotoxy(62,i);
cprintf("%c",219);
gotoxy(18,i);
cprintf("%c",219);
}
textcolor(YELLOW);
gotoxy(20,5);
cprintf("\1");
textcolor(12);
gotoxy(60,20);
cprintf("\2");
gotoxy(20,5);
x=20;
y=5;
textcolor(YELLOW);
t=0;
gotoxy(37,2);
cprintf("TIME:"); /*图象初始化结束*/
for(;;)
{
for(;!kbhit();) /*计时器*/
{
gotoxy(42,2);
if(t%500==0)
cprintf("%d",t/500);
t++;
delay(100);
} /*计时器结束*/
++n;
a=x;
b=y;
key=bioskey(0);
if(key==UP) /*判定按键*/
{
if(y==5)
continue;
gotoxy(x,--y);
WIN;
}
else if(key==DOWN)
{
if(y==20)
continue;
else if(y==5&&x!=60)
continue;
else if(y==7&&x!=50)
continue;
else if(y==9&&x!=40)
continue;
else if(y==11&&x!=30)
continue;
else if(y==13&&x!=20)
continue;
else if(y==15&&x!=25)
continue;
else if(y==17&&x!=55)
continue;
gotoxy(x,++y);
WIN;
}
else if(key==LEFT)
{
if(x==20)
continue;
gotoxy(--x,y);
WIN;
}
else if(key==RIGHT)
{
if(x==60)
continue;
gotoxy(++x,y);
WIN;
}
else if(key==0x11b)
exit(0);
else continue; /*判定结束*/
cprintf("\1"); /*输出图形*/
gotoxy(a,b);
printf(" ");
gotoxy(x,y);
sound(300); /*输出声音*/
delay(1000);
nosound();
}
clrscr(); /*输出结果*/
textcolor(12);
gotoxy(40,10);
cprintf("%c",2);
textcolor(RED);
gotoxy(22,11);
cprintf("After %d days, I will be your wife. %c",n,3);
getch();
}
更多精彩
赞助商链接