本文整理汇总了C++中Maze::getCurrentRoom方法的典型用法代码示例。如果您正苦于以下问题:C++ Maze::getCurrentRoom方法的具体用法?C++ Maze::getCurrentRoom怎么用?C++ Maze::getCurrentRoom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Maze
的用法示例。
在下文中一共展示了Maze::getCurrentRoom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render_map
void rendering::render_map(const Maze& maze, sf::RenderWindow& screen, const std::pair<unsigned int, unsigned int>& pos, const std::pair<unsigned int, unsigned int>& size)
{
/*
First let's figure out the layout of the map !
TODO : This must be done only once for each map, so we have to calculate this when we load a level,
not when we render the map
*/
Room* seed = maze.getSeedRoom();
std::vector<Room*> vec;
std::vector<std::pair<int, int>> positions;
std::vector<std::pair<unsigned int, unsigned int>> coords;
positions.push_back(std::make_pair(0,0));
coords.push_back(std::make_pair(pos.first + size.first/2, pos.second + size.second / 2));
unsigned int cpt = 0;
vec.push_back(seed);
while(cpt < vec.size())
{
Room* piece = vec[cpt];
if(piece == nullptr)
{
infos::log(RENDERING_PATH,"A room is null in render_map, we will not render the rest of the map");
return;
}
if(piece->getNeighboor(NORTH) != nullptr)
{
if (std::find(positions.begin(),positions.end(),std::make_pair(positions[cpt].first,positions[cpt].second - 1)) == positions.end())
{
positions.push_back(std::make_pair(positions[cpt].first,positions[cpt].second - 1));
vec.push_back(piece->getNeighboor(NORTH));
}
}
if (piece->getNeighboor(SOUTH) != nullptr)
{
if(std::find(positions.begin(),positions.end(),std::make_pair(positions[cpt].first,positions[cpt].second + 1)) == positions.end())
{
positions.push_back(std::make_pair(positions[cpt].first,positions[cpt].second + 1));
vec.push_back(piece->getNeighboor(SOUTH));
}
}
if (piece->getNeighboor(WEST) != nullptr)
{
if(std::find(positions.begin(),positions.end(),std::make_pair(positions[cpt].first - 1,positions[cpt].second)) == positions.end())
{
positions.push_back(std::make_pair(positions[cpt].first - 1,positions[cpt].second));
vec.push_back(piece->getNeighboor(WEST));
}
}
if (piece->getNeighboor(EAST) != nullptr)
{
if(std::find(positions.begin(),positions.end(),std::make_pair(positions[cpt].first + 1,positions[cpt].second)) == positions.end())
{
positions.push_back(std::make_pair(positions[cpt].first + 1,positions[cpt].second));
vec.push_back(piece->getNeighboor(EAST));
}
}
++cpt;
}
/* Now that we have the layout, let's figure out the size of each element in the map */
const int minf = std::min_element(positions.begin(),positions.end(),rendering::firstComp)->first; //Minimum for the width
const int mins = std::min_element(positions.begin(),positions.end(),rendering::secondComp)->second; //Minimum for the height
const int maxf = std::max_element(positions.begin(),positions.end(),rendering::firstComp)->first;
const int maxs = std::max_element(positions.begin(),positions.end(),rendering::secondComp)->second;
const int number_room_w = maxf - minf + 1;
const int number_room_h = maxs - mins + 1;
const int width_for_rooms = (static_cast<float>(size.first) / ::quad) * ::quad_for_rooms; // Takes quad_for_rooms/quad % of the full size
const int height_for_rooms = (static_cast<float>(size.second) / ::quad) * ::quad_for_rooms;
const int width_for_blanks = (static_cast<float>(size.first) / ::quad) * ::quad_for_blanks;
const int height_for_blanks = (static_cast<float>(size.second) / ::quad) * ::quad_for_blanks;
const float room_height = height_for_rooms / number_room_h;
const float room_width = width_for_rooms / number_room_w;
const float blank_height = height_for_blanks / (number_room_h + 1);
const float blank_width = width_for_blanks / (number_room_w + 1);
const int line_size_h = blank_height * ::corridors_size;
const int line_size_w = blank_width * ::corridors_size;
const int line_size = std::max(line_size_h,line_size_w);
cpt = 0;
/* Then, let's do the actual rendering */
/* For Debugging purpose, let's log those infos, to see what's messing with the rendering */
for(auto p : positions)
{
Room* piece = vec[cpt];
auto in = maze.getCurrentRoom();
sf::RectangleShape rec;
if(piece == in)
rec.setFillColor(KiroGame::transparent);
//.........这里部分代码省略.........