| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1712 人关注过本帖
标题:萌新,求大佬帮助
只看楼主 加入收藏
yd2457606614
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2018-8-3
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:4 
萌新,求大佬帮助
#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编辑过]

搜索更多相关主题的帖子: int for case cout break 
2018-08-03 22:17
吹水佬
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:451
帖 子:10607
专家分:43186
注 册:2014-5-20
收藏
得分:0 
是不是程序在运行


[此贴子已经被作者于2018-8-4 05:12编辑过]

2018-08-04 05:11
自学的数学
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:46
帖 子:967
专家分:4146
注 册:2017-11-15
收藏
得分:20 
C:\Users\ADMINI~1\AppData\Local\Temp\ccAF2pX4.o    测试点.cpp:(.text+0x60c): undefined reference to `mciSendStringA@16'
C:\Users\ADMINI~1\AppData\Local\Temp\ccAF2pX4.o    测试点.cpp:(.text+0x633): undefined reference to `mciSendStringA@16'
d:\program files\dev-c++\32位\mingw32\mingw32\bin\ld.exe    C:\Users\ADMINI~1\AppData\Local\Temp\ccAF2pX4.o: bad reloc address 0xc in section `.rdata'
d:\program files\dev-c++\32位\mingw32\mingw32\bin\ld.exe    final link failed: Invalid operation
2018-08-04 09:54
yd2457606614
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2018-8-3
收藏
得分:0 
回复 3楼 自学的数学
可以指出错的地方吗
2018-08-04 16:17
自学的数学
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:46
帖 子:967
专家分:4146
注 册:2017-11-15
收藏
得分:0 
[Error] ld returned 1 exit status:
编译的过程中出现这个错误极有可能是因为函数名错误引起的,因此回到源码中观察函数名,尤其是那些库函数中的函数。
2018-08-04 20:03
快速回复:萌新,求大佬帮助
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016935 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved