本文整理汇总了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;
}