当前位置: 首页>>代码示例>>C++>>正文


C++ Command::Interact方法代码示例

本文整理汇总了C++中Command::Interact方法的典型用法代码示例。如果您正苦于以下问题:C++ Command::Interact方法的具体用法?C++ Command::Interact怎么用?C++ Command::Interact使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Command的用法示例。


在下文中一共展示了Command::Interact方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{
    init();
    map = mapLoader.FileMapper();
    int x = mapLoader.GetX();
    int y = mapLoader.GetY();
    char** mapArr = mapLoader.GetMap(map, x, y);
    char** safetyCopy = mapLoader.GetMap(map, x, y);
    ostringstream os;

    Image title = Image("title.txt");
    renderEngine.Render(title);
    getch();
    system("cls");
    mapArr[playerX][playerY] = '0';
    renderEngine.DrawMap(mapArr, x, y);

    while(true) {
        mapArr[playerX][playerY] = safetyCopy[playerX][playerY];
        switch(getch()) {
        case 'w':
            if(playerCanMove('w', safetyCopy[playerX][playerY-1])) {
                playerY--;
            }
            break;
        case 's':
            if(playerCanMove('s', safetyCopy[playerX][playerY+1])) {
                playerY++;
            }
            break;
        case 'a':
            if(playerCanMove('a', safetyCopy[playerX-1][playerY])) {
                playerX--;
            }
            break;
        case 'd':
            if(playerCanMove('d', safetyCopy[playerX+1][playerY])) {
                playerX++;
            }
            break;
        case '0':
            return EXIT_SUCCESS;
            break;
        default:
            break;
        }

        switch(command.Interact(safetyCopy[playerX][playerY])) {
        case 'a':
            pos++;
            os.str("");
            os << "next" << pos << ".txt";
            mapLoader.SetPath(os.str());
            renderEngine.SetEnvironment("fields");
            map = mapLoader.FileMapper();
            x = mapLoader.GetX();
            y = mapLoader.GetY();
            playerX = 20;
            playerY = 2;
            mapArr = mapLoader.GetMap(map, x, y);
            safetyCopy = mapLoader.GetMap(map, x, y);
            break;
        case 'p':
            pos--;
            os.str("");
            os << "next" << pos << ".txt";
            mapLoader.SetPath(os.str());
            renderEngine.SetEnvironment("house");
            map = mapLoader.FileMapper();
            x = mapLoader.GetX();
            y = mapLoader.GetY();
            playerX = 8;
            playerY = 12;
            mapArr = mapLoader.GetMap(map, x, y);
            safetyCopy = mapLoader.GetMap(map, x, y);
            break;
        case 'n':
            break;
        }
        system("cls");
        mapArr[playerX][playerY] = '0';
        renderEngine.DrawMap(mapArr, x, y);
    }

    return EXIT_SUCCESS;

}
开发者ID:Pandarai,项目名称:RogueLike,代码行数:87,代码来源:main.cpp


注:本文中的Command::Interact方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。