有个课程设计的题目比较难啊 有高手帮我吗?用的是TC2.0
要先做个选择界面 选择难度 进入和退出,在进行游戏时按ESC可以回到选择界面
游戏界面要有个小人和个宝藏 小人可以上下左右移动 到达宝藏后自动返回带选择界面
我编了点游戏界面程序 帮我搞下啊
#include "stdafx.h"
#include "stdio.h"
#include "conio.h"
#include "string.h"
#include "stdlib.h"
void main()
{
loop: int i,j,temp;
char k,m[10];
int x=22,y=23;
int a[24][25]=
{
1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,0,1,0,1,1,1,0,1,0,1,1,1,0,1,1,1,1,1,0,1,0,1,1,1,
1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,
1,0,1,0,1,1,1,0,1,0,1,1,1,0,1,0,1,1,1,0,1,0,1,1,1,
1,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,1,0,0,0,1,
1,0,1,0,1,1,1,0,1,1,1,1,1,0,1,0,1,1,1,1,1,0,1,0,1,
1,0,0,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1,
1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,1,0,1,1,1,0,1,
1,0,1,0,1,0,0,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,1,
1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,1,1,1,1,
1,0,0,0,0,0,1,0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,1,0,1,
1,1,1,0,1,1,1,0,1,0,1,1,1,0,1,0,1,0,1,1,1,0,1,0,1,
1,0,0,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,
1,1,1,0,1,1,1,0,1,0,1,1,1,0,1,0,1,1,1,0,1,1,1,0,1,
1,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,1,0,0,0,1,
1,0,1,1,1,1,1,0,1,0,1,0,1,1,1,0,1,0,1,1,1,1,1,0,1,
1,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,1,
1,0,1,1,1,0,1,1,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,1,1,
1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,
1,0,1,0,1,1,1,0,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,0,1,
1,0,1,0,0,0,1,0,1,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,
1,0,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,0,1,1,1,1,1,1,1,
1,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
} ;
temp=a[x][y];
a[x][y]=2;
for (i=0;i<24;i++)
{
for (j=0;j<25;j++)
printf("%c",a[i][j]);
printf("\n"); /*打印地图*/
}
k=getchar();
if(!k)
k=getchar();
do
{
a[x][y]=temp;
switch (k)
{
case 'a': if (a[x][y-1]==0) y=y-1;break;
case 'd': if (a[x][y+1]==0) y=y+1;break;
case 'w': if (a[x-1][y]==0 ) x=x-1;break;
case 's': if (a[x+1][y]==0 ) x=x+1;break;
default : break;
}
temp=a[x][y];
a[x][y]=2;
for (i=0;i<24;i++)
{
for (j=0;j<25;j++)
printf("%c",a[i][j]);
printf("\n");
} /*完成移动操作*/
if (a[0][1]==2)
{
printf("Well done!!!\n Do you want to try it again?(y/n)");
scanf("%s",m);
if(strcmp(m,"y")==0)
{
goto loop; /*重新开始*/
}
else
break;
}
k=getchar();
if(!k)
k=getchar();
system("cls");
}while (k!=0);
}
----------------解决方案--------------------------------------------------------
平时怎么学的呢?
什么叫学到用时方恨少?
建议用google搜索一下
“搬运工”游戏的代码。
----------------解决方案--------------------------------------------------------