萌新,求大佬帮助
#include<iostream>#include<Windows.h>
#include<conio.h>
#include<cstdio>
//控制台的输入输出; //mspaind在cmd中打开画图。
using namespace std;
int mmap[8][10]={(0,0,0,1,1,1,0,0,0,0),
(0,0,0,1,3,1,0,0,0,0),
(0,0,0,1,0,1,1,1,1,0),
(0,1,1,1,4,0,4,3,1,0),
(0,1,3,0,4,5,1,1,1,0),
(0,1,1,1,1,4,1,0,0,0),
(0,0,0,0,1,3,1,0,0,0),
(0,0,0,0,1,1,1,0,0,0)};
void Draw_Map(){
for (int i = 0; i < 8; i++){
for(int j = 0; j < 10;j++){
switch(mmap[i][j]){
case 0:cout<<" ";break;
case 1:cout<<"#";break;
case 3:cout<<"*";break;
case 4:cout<<"$";break;
case 5:cout<<"a";break;}
}
}
};
void PlayGame(){
int x,y;
for(int i = 0;i < 8; i++){
for(int j = 0; j < 10;j++){
if(mmap[i][j] == 5){
x = i;
y = j;
}
}
}
char ch;
ch =getch();
switch(ch){
case 'W':
case 'w':if(mmap[x - 1][y] == 0){
mmap[x - 1][y] = 5;
mmap[x][y] = 0;
}else if (mmap[x-1][y]==4){
if (mmap[x -2][y] ==0||mmap[x - 2][y] == 3){
mmap[x - 2][y] = 4;
mmap[x -1][y] = 5;
mmap[x][y]=0;
}
}
break;
case 'S':
case 's':if(mmap[x + 1][y] == 0){
mmap[x + 1][y] = 5;
mmap[x][y] = 0;
}else if (mmap[x+1][y]==4){
if (mmap[x + 2][y] ==0||mmap[x + 2][y] == 3){
mmap[x + 2][y] = 4;
mmap[x + 1][y] = 5;
mmap[x][y]=0;
}
}
break;
case 'A':
case 'a':if(mmap[x][y-1] == 0){
mmap[x][y-1] = 5;
mmap[x][y] = 0;
}else if (mmap[x][y-1]==4){
if (mmap[x][y-2] ==0||mmap[x][y-2] == 3){
mmap[x][y-2] = 4;
mmap[x][y-1] = 5;
mmap[x][y]=0;
}
}
break;
case 'D':
case 'd':if(mmap[x][y+1] == 0){
mmap[x][y+1] = 5;
mmap[x][y] = 0;
}else if (mmap[x][y+1]==4){
if (mmap[x][y+2] ==0||mmap[x][y+2] == 3){
mmap[x][y+2] = 4;
mmap[x][y+1] = 5;
mmap[x][y]=0;
}
}
break;
}
}
int main(){
mciSendString("open ",0,0,0);//打开音频
mciSendString("play",0,0,0);
while (1){
Draw_Map();
PlayGame();
}
return 0;
}
[Error] ld returned 1 exit status
[此贴子已经被作者于2018-8-3 22:20编辑过]