void place_coins()

in coinrun/coinrun.cpp [598:621]


  void place_coins()
  {
    int coins = 0;
    while (!rec_stack.empty()) {
      Rec r = rec_stack[rec_stack.size()-1];
      rec_stack.pop_back();
      int x = r.x;
      int y = r.y;
      bool good_place =
        maze->get_elem(x, y) == SPACE &&
        r.y > 2 &&
        maze->get_elem(x-1, y) == SPACE &&
        maze->get_elem(x+1, y) == SPACE &&
        maze->get_elem(x, (y+1)) == SPACE &&
        is_wall(maze->get_elem(x-1, y-1), true) &&
        is_wall(maze->get_elem(x, y-1), true) &&
        is_wall(maze->get_elem(x+1, y-1), true);
      if (good_place) {
        maze->set_elem(x, y, '1');
        coins += 1;
      }
    }
    maze->coins = coins;
  }