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


C++ Maze::getMaze方法代码示例

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


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

示例1: processMovement

void Logic::processMovement(Pacman &pacman, Maze &maze)
{
	Vector2<int> coords(0,0);

	switch(pacman.getDirection())	
	{
		case Direction::UP:
			coords.x = pacman.getPosition().x;
			coords.y = pacman.getPosition().y - 1;
			break;

		case Direction::DOWN:
			coords.x = pacman.getPosition().x;
			coords.y = pacman.getPosition().y + 1;
			break;

		case Direction::LEFT:
			coords.x = pacman.getPosition().x - 1;
			coords.y = pacman.getPosition().y;
			break;

		case Direction::RIGHT:
			coords.x = pacman.getPosition().x + 1;
			coords.y = pacman.getPosition().y;
			break;

		case Direction::STOP:
			coords.x = pacman.getPosition().x;
			coords.y = pacman.getPosition().y;
			break;
	}

	if(maze.getMaze()[coords.x][coords.y].getType() != Type::NOTHING)
	{
		if(Physics::isIntersects(&pacman, &maze.getMaze()[coords.x][coords.y], pacman.getDirection()))
		{
			switch(maze.getMaze()[coords.x][coords.y].getType())
			{
			case Type::PILL:
					pacman.setScore(pacman.getScore() + 2);
					maze.getMaze()[coords.x][coords.y].setType(Type::NOTHING);
					cellsToChange.setXY(coords.x, coords.y);
					break;

				case Type::BONUS:
					break;

				case Type::WALL:
					pacman.setDirection(Direction::STOP);
					break;
			}
		}
	}

	pacman.setMovingVector();
}
开发者ID:RoastedBard,项目名称:Pacman,代码行数:56,代码来源:Logic.cpp

示例2: ErrorBomberman

void	IA::update(GameEngine *game, Maze &maze)	{
  std::list<Bomb *>::iterator		it_bomb = this->m_bomb.begin();
  int	action;
  int	x;
  int	y;

  if (this->m_time > 42) {
    this->m_time = 0;
    x = this->m_position % this->m_width;
    y = this->m_position / this->m_width;
    this->IsAlive(maze);
    if (this->m_alive) {
      action = this->m_lua->getPosition(maze.getMaze(), x, y);
      if (action == -1)
	throw ErrorBomberman("Error with lua bind", "IA");
      else if (action < IA_NONE)
	(this->*m_func[action])(maze, game->getClock());
    }
  }
  this->m_time = this->m_time + 1;
  try {
    while (it_bomb != this->m_bomb.end()) {
      (*it_bomb)->update(game->getClock(), maze);
      if ((*it_bomb)->getState() == TODELETE) {
	delete *it_bomb;
	it_bomb = this->m_bomb.erase(it_bomb);
      }
      ++it_bomb;
    }
  }
  catch (ErrorBomberman const &e) {
    throw ErrorBomberman(e.what(), "IA");
  }
}
开发者ID:Ankirama,项目名称:Epitech,代码行数:34,代码来源:IA.cpp

示例3:

void	IA::MoveDown(Maze &maze, gdl::Clock &)	{
  if (this->m_alive == true) {
    this->m_direction = DOWN;
    this->m_tomove = this->move(maze.getMaze(), maze.getWidth());
  }
}
开发者ID:Ankirama,项目名称:Epitech,代码行数:6,代码来源:IA.cpp


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