本文整理汇总了C++中map::getMax方法的典型用法代码示例。如果您正苦于以下问题:C++ map::getMax方法的具体用法?C++ map::getMax怎么用?C++ map::getMax使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map
的用法示例。
在下文中一共展示了map::getMax方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: victoryCheck
//return true if the player has reached 'x'
bool victoryCheck() {
if (thePlayer.getPlayerX() == theMap.getMax() && thePlayer.getPlayerY() == theMap.getMax()){
level++;
return true;
}
else {
return false;
}
}
示例2: newRoom
//wipe the room, expand it if needed, and reset locations
void newRoom() {
int x, y;
//the dungeon has a max size of 20
if (level > 20) {
theMap.blankRoom(20);
}
else {
theMap.blankRoom(level);
}
//setup player
theMap.insertElement('P', 0, 0);
thePlayer.setPlayerLocation(0, 0);
//setup exit
theMap.insertElement('X', theMap.getMax(), theMap.getMax());
//setup NORMAL_TRAPS
for (int i = 0; i != level; i++) {
x = rand() % theMap.getMax();
y = rand() % theMap.getMax();
while (theMap.getElement(x, y) != ' ') {
x = rand() % theMap.getMax();;
y = rand() % theMap.getMax();;
}
theEnemies.addEnemy(pTheMap, "NORMAL_TRAP", x, y);
}
//setup GRUNTS
for (int i = 0; i != level / 2; i++) {
x = rand() % theMap.getMax();
y = rand() % theMap.getMax();
while (theMap.getElement(x, y) != ' ') {
x = rand() % theMap.getMax();
y = rand() % theMap.getMax();
}
theEnemies.addEnemy(pTheMap, "GRUNT", x, y);
}
//setup STALKERS
for (int i = 0; i != level / 5 ; i++) {
x = rand() % theMap.getMax();
y = rand() % theMap.getMax();
while (theMap.getElement(x, y) != ' ') {
x = rand() % theMap.getMax();
y = rand() % theMap.getMax();
}
theEnemies.addEnemy(pTheMap, "STALKER", x, y);
}
//setup ITEM
if (int r = rand() % 10 + 1 == 1) {
x = rand() % theMap.getMax();
y = rand() % theMap.getMax();
while (theMap.getElement(x, y) != ' ') {
x = rand() % theMap.getMax();
y = rand() % theMap.getMax();
}
theMap.insertElement('*', x, y);
}
}
示例3: gameLoop
//the main game loop
void gameLoop() {
hasMoved = false;
//draw screen
theMap.drawMap();
cout << "Level: " << level << " - 'h' for help " << endl;
if (thePlayer.getItem() != "NONE") {
cout << "Type 'f' to use '" << thePlayer.getItem() << "'." << endl;
}
//player turn
while (!hasMoved) {
moveInput = _getch();
//player move
if (moveInput == 'w' || moveInput == 'a' || moveInput == 's' || moveInput == 'd') {
hasMoved = thePlayer.playerMove(pTheMap, pTheEnemies, pTheItems, moveInput);
}
else if (moveInput == 'h') {
help();
//redraw screen
theMap.drawMap();
cout << "Level: " << level << endl;
}
else if (moveInput == 'f') {
//use item
theItems.useItem(pTheMap, thePlayer.getPlayerLocation(), thePlayer.getItem());
thePlayer.removeItem();
//redraw screen without the 'type f to use' etc
theMap.drawMap();
cout << "Level: " << level << " - 'h' for help " << endl;
}
}
//death check
if (thePlayer.isDead()) {
isPlaying = false;
}
// victory check
if (victoryCheck()) {
newRoom();
return;
}
//enemies act
for (int x = 0; x < theMap.getMax(); x++) {
for (int y = 0; y != theMap.getMax(); y++) {
if (theEnemies.isEnemy(pTheMap, x, y)) {
if (theMap.getElement(x, y) == 'm') {
theEnemies.moveEnemy(pTheMap, thePlayer.getPlayerLocation(), "GRUNT", x, y);
}
else if (theMap.getElement(x, y) == 'M') {
theEnemies.moveEnemy(pTheMap, thePlayer.getPlayerLocation(), "STALKER", x, y);
}
}
}
}
//Change new enemy placements to valid enemy placements
for (int i = 0; i < theMap.getMax(); i++) {
for (int a = 0; a < theMap.getMax(); a++) {
if (theMap.getElement(i, a) == 'n') {
theMap.insertElement('m', i, a);
}
if (theMap.getElement(i, a) == 'N') {
theMap.insertElement('M', i, a);
}
}
}
// - victory check
}