本文整理汇总了C++中Door::setX方法的典型用法代码示例。如果您正苦于以下问题:C++ Door::setX方法的具体用法?C++ Door::setX怎么用?C++ Door::setX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Door
的用法示例。
在下文中一共展示了Door::setX方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generate
//.........这里部分代码省略.........
if( roomY < 0 ) roomY = 0;
if( roomX < 0 ) roomX = 0;
if( roomX >= static_cast<int>(m_width) ) roomX = m_width - 1;
if( roomY >= static_cast<int>(m_height) ) roomX = m_height - 1;
// Make the new room.
Room* newRoom = new Room(roomX, roomY, roomW, roomH, currentRoom);
// Check if it's valid placement.
if(newRoom->validPlacement(tiles, m_width, m_height))
{
// Fill the tiles with the room.
newRoom->fill(tiles);
fillAreaWithFog(newRoom);
// Add the room to the vector.
rooms.push_back(newRoom);
// Remove the succeded Direction, because it's not available again.
//currentRoom->removeDirection(direction);
// Remove the opposite direction of current room.
switch((int)direction)
{
case 0: newRoom->removeDirection(Direction::DOWN); break;
case 1: newRoom->removeDirection(Direction::UPP); break;
case 2: newRoom->removeDirection(Direction::RIGHT); break;
case 3: newRoom->removeDirection(Direction::LEFT); break;
}
// Set the current room to the new room.
currentRoom = newRoom;
// Alter the supposedly connected walls so a pathway is formed.
Door* door = static_cast<Door*>( EntityFactory::get()->createEntity("door") );
door->setX(doorAX*32);
door->setY(doorAY*32);
door->setConnectedRoom(currentRoom);
door->setFogmap(&m_fogmap);
tiles[doorAX][doorAY] = 1;
}
else
{
// Remove the room that failed.
delete newRoom;
// Remove the direction that failed
currentRoom->removeDirection(direction);
// If there are no more directions to go in the current room.
if(currentRoom->possibleDirections() == 0)
{
// Move back one room and try to generate rooms in other directions
Room* connectedRoom = currentRoom->getConnected();
// If the connected room is start room then there is NO more to be done.
if(connectedRoom == nullptr)
{
break;
}
// Set the current room to the room before.
currentRoom = connectedRoom;
}
}
}
rooms[0]->showRoom(m_fogmap);
int stairIndex = rand() % rooms.size();
float stx = rooms[stairIndex]->getX() + rooms[stairIndex]->getWidth() / 2;
float sty = rooms[stairIndex]->getY() + rooms[stairIndex]->getHeight()/ 2;
Stairway* stairway = static_cast<Stairway*>(EntityFactory::get()->createEntity("stairway"));
stairway->setX(stx*32);
stairway->setY(sty*32);
stairway->setGameState(state);
std::ofstream ofs;
ofs.open("level.txt");
for( unsigned int y = 0; y < m_height; y++ )
{
for( unsigned int x = 0; x < m_width; x++ )
{
if( tiles[x][y] == 0)
ofs << " ";
else if ( tiles[x][y] == 2 || tiles[x][y] == 3 || tiles[x][y] == 4 )
ofs << "W";
else if ( tiles[x][y] == 5 )
ofs << "D";
else
ofs << "#";
}
ofs << "\n";
}
ofs.close();
}