本文整理汇总了C++中map::drawMap方法的典型用法代码示例。如果您正苦于以下问题:C++ map::drawMap方法的具体用法?C++ map::drawMap怎么用?C++ map::drawMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map
的用法示例。
在下文中一共展示了map::drawMap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: displayMe
//game screen graphics
void displayMe(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/*BACKGROUND COLOR
glBegin(GL_QUADS);
glColor4f(0.5f, 0.0f, 1.0f, 0.7); // (0.5, 0, 1) is half red and full blue, giving dark purple.
//menu rectangle
glVertex2f(-1, -1);
glVertex2f(-1, 1);
glVertex2f(1, 1);
glVertex2f(1, -1);
glEnd();
*/
glColor4f(1,1,1,0.5);
displayScore(lives);
p.drawPaddle();
b.drawBall();
m.drawMap();
//if paused aka main menu is displayed
switch(state){
case GAME_ACTIVE: //main mode
p.movePaddle(mouseX,0);
b.moveBall(p, &m, lives);
break;
case GAME_PAUSED: //main menu state
mainMenu();
break;
case GAME_ABOUT: //about screen
showAboutScreen();
break;
default: // cannot be here
cout << "Fatal error" << endl;
exit(0);
break;
}
glutSwapBuffers();
}
示例2: 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
}