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


C++ Floor::newGame方法代码示例

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


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

示例1: main

int main(int argc, const char * argv[]) {
  char command;
  char dir;
  char race;
  string s;
  Floor* f;
  bool end = false;
  int score;
  
  ifstream in("welcome.txt");	// welcome page
  while (getline(in, s)) {
    cout << s << endl;
  }
  
  while (true) {		// determine if whitespace is pressed
    cin >> command;
    if (command == 'c') {
      break;
    }
    if (command == 'q') {
      return 0;
    }
  }
  
  f = new Floor(25, 79);	// choose race
  f->init(argv[1]);
  cout << "please choose your race" << endl;
  cout << "h: human" << endl;
  cout << "d: dwarf" << endl;
  cout << "e: evlves" << endl;
  cout << "o: orc" << endl;
  cout << "i: ironman" << endl;
  
  while (true) {
    cin >> race;	// specify race
    if (race == 'q') return 0;
    else if (race == 'h' || race == 'e' || race == 'd' || race == 'o' ||
             race == 'i') break;
    else cout << "no such race" << endl;
  }
  
  switch(race) {	// spawn pc and stair
    case 'h':
      character = new Human;
      f->newGame(character);
      break;
    case 'e':
      character = new Elves;
      f->newGame(character);
      break;
    case 'd':
      character = new Dwarf;
      f->newGame(character);
      break;
    case 'o':
      character = new Orc;
      f->newGame(character);
      break;
    case 'i':
      character = new Ironman;
      f->newGame(character);
      break;
  }
  f->enemyMove();
  f->notifyTd();
  cout << *f;
  
  while (true) {
    if (character->getHp() <= 0) {	// determine if PC is dead
      ifstream in("lose.txt");
      while(getline(in, s)) {
        cout << s << endl;
      }
      score = character->getGold();
      if (character->getRace() == "human") {
        score += score / 2;
      }
      cout << "Your Score is: " << score << endl;
      end = true;
    }
    
    cin >> command;
    
    if (end == true) {	// wait for r or q after previous game
      while (command != 'r' && command != 'q') {
        cin >> command;
      }
      end = false;
    }
    
    switch(command) {
      case 'n':		// move
        cin >> dir;
        switch(dir) {
          case 'w':	
            f->pcMove(0);
            break;
          case 'o':
            f->pcMove(1);
            break;
//.........这里部分代码省略.........
开发者ID:Barrymn,项目名称:RogueGame,代码行数:101,代码来源:main.cpp


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