本文整理汇总了C++中Level类的典型用法代码示例。如果您正苦于以下问题:C++ Level类的具体用法?C++ Level怎么用?C++ Level使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Level类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generateLevels
void generateLevels()
{
levels_ = std::vector<Level>( 100 );
for( std::size_t i = 0 ; i < 100 ; i++ )
{
Level level;
for( std::size_t ii = 0 ; ii < 50000 ; ii++ )
{
makeRoomSilentlyFail( level );
if( level.rooms.size() == 99 )
{
break;
}
}
level.fillTiles();
levels_.push_back( level );
}
}
示例2: call
void BarycenterHeuristic::call (Level &L)
{
const Hierarchy& H = L.hierarchy();
for (int i = 0; i <= L.high(); ++i) {
node v = L[i];
long sumpos = 0L;
const Array<node> &adjNodes = L.adjNodes(v);
for(int j = 0; j <= adjNodes.high(); ++j)
sumpos += H.pos(adjNodes[j]);
m_weight[v] = (adjNodes.high() < 0) ? 0.0 :
double(sumpos) / double(adjNodes.size());
}
L.sort(m_weight);
}
示例3: TEUCHOS_TEST_FOR_EXCEPTION
void BlockedCoarseMapFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::DeclareInput(Level ¤tLevel) const {
this->Input(currentLevel, "Aggregates");
this->Input(currentLevel, "Nullspace");
// Get CoarseMap from previously defined block
RCP<const FactoryBase> prevCoarseMapFact = this->GetFactory("CoarseMap");
TEUCHOS_TEST_FOR_EXCEPTION(prevCoarseMapFact==Teuchos::null, Exceptions::RuntimeError, "MueLu::BlockedCoarseMapFactory::getDomainMapOffset: user did not specify CoarseMap of previous block. Do not forget to set the CoarseMap factory.");
currentLevel.DeclareInput("CoarseMap", prevCoarseMapFact.get(), this); // --
}
示例4: save_level
void save_level (FILE* file, const Level& level) {
fprintf(file, "Level: %d x %d\n", level.w, level.h);
for (int y = 0; y < level.h; ++y) {
for (int x = 0; x < level.w; ++x) {
save_tile(file, level.tile(x, y));
}
fprintf(file, "\n");
}
}
示例5: m
void UserAggregationFactory<LocalOrdinal, GlobalOrdinal, Node, LocalMatOps>::Build(Level ¤tLevel) const {
FactoryMonitor m(*this, "Build", currentLevel);
const ParameterList & pL = GetParameterList();
RCP< const Teuchos::Comm<int> > comm = Teuchos::DefaultComm<int>::getComm();
const int myRank = comm->getRank();
std::string fileName = pL.get<std::string>("filePrefix") + toString(currentLevel.GetLevelID()) + "_" + toString(myRank) + "." + pL.get<std::string>("fileExt");
std::ifstream ifs(fileName.c_str());
if (!ifs.good())
throw Exceptions::RuntimeError("Cannot read data from \"" + fileName + "\"");
LO numVertices, numAggregates;
ifs >> numVertices >> numAggregates;
// FIXME: what is the map?
Xpetra::UnderlyingLib lib = Xpetra::UseEpetra;
const int indexBase = 0;
RCP<Map> map = MapFactory::Build(lib, numVertices, indexBase, comm);
RCP<Aggregates> aggregates = rcp(new Aggregates(map));
aggregates->setObjectLabel("User");
aggregates->SetNumAggregates(numAggregates);
Teuchos::ArrayRCP<LO> vertex2AggId = aggregates->GetVertex2AggId()->getDataNonConst(0);
Teuchos::ArrayRCP<LO> procWinner = aggregates->GetProcWinner() ->getDataNonConst(0);
for (LO i = 0; i < numAggregates; i++) {
int aggSize = 0;
ifs >> aggSize;
std::vector<LO> list(aggSize);
for (int k = 0; k < aggSize; k++) {
// FIXME: File contains GIDs, we need LIDs
// for now, works on a single processor
ifs >> list[k];
}
// Mark first node as root node for the aggregate
aggregates->SetIsRoot(list[0]);
// Fill vertex2AggId and procWinner structure with information
for (int k = 0; k < aggSize; k++) {
vertex2AggId[list[k]] = i;
procWinner [list[k]] = myRank;
}
}
// FIXME: do the proper check whether aggregates cross interprocessor boundary
aggregates->AggregatesCrossProcessors(false);
Set(currentLevel, "Aggregates", aggregates);
GetOStream(Statistics0, 0) << aggregates->description() << std::endl;
}
示例6: clearLevelData
void Season::initLevels(int startLevel) {
clearLevelData();
QuestionSet* q = g_SeasonQuestions[m_id];
int qCount = q->count();
int levelCount = qCount / MAX_LEVEL_QUESTION_COUNT+ ((qCount % MAX_LEVEL_QUESTION_COUNT) ? 1 : 0);
for (int i = 0; i < levelCount; i++) {
Level* level = new Level(i+startLevel, m_id);
int start = i * MAX_LEVEL_QUESTION_COUNT;
int end = start + MAX_LEVEL_QUESTION_COUNT;
for ( int j = start; j < end && j < qCount; j++) {
level->addQuestion(q->question(j));
}
if (level->level() == 1)
level->unlock();
m_levels.insert(pair<int, Level*>(level->level(), level));
}
}
示例7: Input
void BlockedPFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps>::DeclareInput(Level &fineLevel, Level &coarseLevel) const {
Input(fineLevel, "A");
//fineLevel.DeclareInput("A",AFact_.get(),this);
//Teuchos::RCP<Teuchos::FancyOStream> fos = Teuchos::getFancyOStream(Teuchos::rcpFromRef(std::cout));
std::vector<Teuchos::RCP<const FactoryManagerBase> >::const_iterator it;
for(it = FactManager_.begin(); it!=FactManager_.end(); ++it) {
SetFactoryManager fineSFM (rcpFromRef(fineLevel), *it);
SetFactoryManager coarseSFM(rcpFromRef(coarseLevel), *it);
if (!restrictionMode_)
coarseLevel.DeclareInput("P",(*it)->GetFactory("P").get(), this);
else
coarseLevel.DeclareInput("R",(*it)->GetFactory("R").get(), this);
}
}
示例8: Input
void UncoupledAggregationFactory_kokkos<LocalOrdinal, GlobalOrdinal, Node>::DeclareInput(Level& currentLevel) const {
Input(currentLevel, "Graph");
Input(currentLevel, "DofsPerNode");
const ParameterList& pL = GetParameterList();
// request special data necessary for OnePtAggregationAlgorithm
std::string mapOnePtName = pL.get<std::string>("OnePt aggregate map name");
if (mapOnePtName.length() > 0) {
std::string mapOnePtFactName = pL.get<std::string>("OnePt aggregate map factory");
if (mapOnePtFactName == "" || mapOnePtFactName == "NoFactory") {
currentLevel.DeclareInput(mapOnePtName, NoFactory::get());
} else {
RCP<const FactoryBase> mapOnePtFact = GetFactory(mapOnePtFactName);
currentLevel.DeclareInput(mapOnePtName, mapOnePtFact.get());
}
}
}
示例9: TEUCHOS_TEST_FOR_EXCEPTION
void BraessSarazinSmoother<Scalar, LocalOrdinal, GlobalOrdinal, Node>::DeclareInput(Level& currentLevel) const {
this->Input(currentLevel, "A");
TEUCHOS_TEST_FOR_EXCEPTION(FactManager_.is_null(), Exceptions::RuntimeError,
"MueLu::BraessSarazinSmoother::DeclareInput: FactManager_ must not be null! "
"Introduce a FactoryManager for the SchurComplement equation.");
// carefully call DeclareInput after switching to internal FactoryManager
{
SetFactoryManager currentSFM(rcpFromRef(currentLevel), FactManager_);
// request "Smoother" for current subblock row.
currentLevel.DeclareInput("PreSmoother", FactManager_->GetFactory("Smoother").get());
// request Schur matrix just in case
currentLevel.DeclareInput("A", FactManager_->GetFactory("A").get());
}
}
示例10: m
void RebalanceMapFactory<LocalOrdinal, GlobalOrdinal, Node>::Build(Level &level) const {
FactoryMonitor m(*this, "Build", level);
//Teuchos::RCP<Teuchos::FancyOStream> fos = Teuchos::getFancyOStream(Teuchos::rcpFromRef(std::cout));
// extract data from Level object
const Teuchos::ParameterList & pL = GetParameterList();
std::string mapName = pL.get<std::string> ("Map name");
Teuchos::RCP<const FactoryBase> mapFactory = GetFactory ("Map factory");
RCP<const Import> rebalanceImporter = Get<RCP<const Import> >(level, "Importer");
if(rebalanceImporter != Teuchos::null) {
// input map (not rebalanced)
RCP<const Map> map = level.Get< RCP<const Map> >(mapName,mapFactory.get());
// create vector based on input map
// Note, that the map can be a part only of the full map stored in rebalanceImporter.getSourceMap()
RCP<Vector> v = VectorFactory::Build(map);
v->putScalar(1.0);
// create a new vector based on the full rebalanceImporter.getSourceMap()
// import the partial map information to the full source map
RCP<const Import> blowUpImporter = ImportFactory::Build(map, rebalanceImporter->getSourceMap());
RCP<Vector> pv = VectorFactory::Build(rebalanceImporter->getSourceMap());
pv->doImport(*v,*blowUpImporter,Xpetra::INSERT);
// do rebalancing using rebalanceImporter
RCP<Vector> ptv = VectorFactory::Build(rebalanceImporter->getTargetMap());
ptv->doImport(*pv,*rebalanceImporter,Xpetra::INSERT);
if (pL.get<bool>("repartition: use subcommunicators") == true)
ptv->replaceMap(ptv->getMap()->removeEmptyProcesses());
// reconstruct rebalanced partial map
Teuchos::ArrayRCP< const Scalar > ptvData = ptv->getData(0);
std::vector<GlobalOrdinal> localGIDs; // vector with GIDs that are stored on current proc
for (size_t k = 0; k < ptv->getLocalLength(); k++) {
if(ptvData[k] == 1.0) {
localGIDs.push_back(ptv->getMap()->getGlobalElement(k));
}
}
const Teuchos::ArrayView<const GlobalOrdinal> localGIDs_view(&localGIDs[0],localGIDs.size());
Teuchos::RCP<const Map> localGIDsMap = MapFactory::Build(
map->lib(),
Teuchos::OrdinalTraits<int>::invalid(),
localGIDs_view,
0, ptv->getMap()->getComm()); // use correct communicator here!
// store rebalanced partial map using the same name and generating factory as the original map
// in the level class
level.Set(mapName, localGIDsMap, mapFactory.get());
}
} //Build()
示例11: restore
void InterlevelScene::restore()
{
Actor::fixTime();
GameLog::wipe();
Dungeon::loadGame(StartScene::curClass);
if (Dungeon::depth == -1)
{
Dungeon::depth = Statistics::deepestFloor;
Dungeon::switchLevel(Dungeon::loadLevel(StartScene::curClass), -1);
}
else
{
Level* level = Dungeon::loadLevel(StartScene::curClass);
Dungeon::switchLevel(level, Level::resizingNeeded ? level->adjustPos(Dungeon::hero->pos) : Dungeon::hero->pos);
}
}
示例12: main
int main(int argc, char** argv) {
sf::RenderWindow App(sf::VideoMode(1280,720),"Savage Heat: A bit Harder than the Corps");
App.setFramerateLimit(60);
//App.setVerticalSyncEnabled(true);
BulletTracker bulletList;
sf::Texture tex = loadImage("Images/Player1.bmp");
sf::Texture tex2 = loadImage("Images/Bullet2.bmp");
sf::Clock clock;
Level disLevel;
Player p1(tex,tex2);
p1.name = "Player 1";
while(App.isOpen()){
sf::Event event;
sf::Time time = clock.restart();
float elapsed = time.asSeconds();
while(App.pollEvent(event)){
if(event.type == sf::Event::Closed){
App.close();
}
if(event.type == sf::Event::KeyPressed){
if(event.key.code == sf::Keyboard::F11){
}
if(event.key.code == sf::Keyboard::Escape){
App.close();
}
}
}
p1.update((1.f/60.f)/*elapsed*/, disLevel, bulletList);
bulletList.update((1.f/60.f)/*elapsed*/);
disLevel.updateView(p1.Sprite, (1.f/60.f)/*elapsed*/);
App.setView(disLevel.playerView);
App.clear();
disLevel.drawLevel(App,p1.Sprite);
bulletList.draw(App);
App.draw(p1.Sprite);
App.display();
}
}
示例13: Assert
void PoolSnapshot::CreateFromCurrentState()
{
// Get the state of all game objects in the current room.
Level* pLevel = LevelServer::Instance()->GetCurrentLevel().GetPtr();
int levelId = pLevel->GetId();
int roomId = pLevel->GetRoomId();
GameObjectMap& objs = Engine::Instance()->GetGameObjects(levelId, roomId);
// Iterate through map of Game Objects.
for (GameObjectMap::iterator it = objs.begin(); it != objs.end(); ++it)
{
PPoolGameObject pGo = it->second;
Assert(pGo.GetPtr());
#ifdef UNDO_DEBUG
if (gameObjId == 10)
std::cout << "** UNDO: Storing cue ball: pos is "
<< ToString(*(pGo->GetOrientation()))
<< "\n";
#endif
ObjInfo info;
info.m_pGo = pGo;
if (pGo->GetOrientation())
{
info.m_or = *(pGo->GetOrientation());
}
info.m_state = pGo->GetState();
m_objInfo.push_back(info);
}
// No of ball spotted by each player
int numPlayers = Engine::Instance()->GetGameState()->GetNumberOfPlayers();
for (int i = 0; i < numPlayers; i++)
{
m_playerInfo.push_back(
*(Engine::Instance()->GetGameState()->GetPlayerInfo(i)));
}
// Store the state of the Rules - like is this a free ball, can the
// ball be placed anywhere, etc.
m_pRules = GetRules(pLevel)->Clone();
}
示例14: genLevelBlueprint
void WorldGenerator::genLevel( Level& level, LevelGenerationRanges& ranges, uint seed, float blockDimension, XMFLOAT3& spawn )
{
mRand.seed( seed );
//Generate number of rooms that will exist in the level and allocate space for it
int roomCount = ranges.roomCount.gen( mRand );
Room* rooms = new Room[ roomCount ];
mLevelRanges = &ranges;
//Gen the rooms that make up the level
genLevelBlueprint( level, rooms, (short)(roomCount) );
//Set the first room to empty
rooms[0].type = Room::Type::Empty;
//For each room, do a pass generating the heights, furniture, containers, and walls
//for(int i = 0; i < roomCount; i++){
//genLevelRoomHeights( level, rooms[i] );
//}
//Do a pass on each room, generating each of the following
for(int i = 0; i < roomCount; i++){
genLevelRoomWalls( level, rooms[i] );
genLevelRoomFurniture( level, rooms[i], blockDimension );
genLevelRoomContainers( level, rooms[i], blockDimension );
genLevelRoomLights( level, rooms[i] );
}
LOG_INFO << "Generated Level: " << level.getWidth() << ", " << level.getDepth() << LOG_ENDL;
LOG_INFO << "Level has " << roomCount << " rooms " << LOG_ENDL;
//Set the spawn point
for(int i = 0; i < ROOM_MAX_DOORS; i++){
if( rooms[0].doors[i].essential ){
spawn.x = static_cast<float>(rooms[0].doors[i].x) * blockDimension;
spawn.y = 0.0f;
spawn.z = static_cast<float>(rooms[0].doors[i].y) * blockDimension;
}
}
delete[] rooms;
rooms = NULL;
}
示例15: Update
void PlayerCamera::Update( float dt, Player& player, Input& input, Level& level )
{
int newPosX = 0,
newPosY = 0;
//if(input.GetMouseButtonState(4))
//{
// m_zoomLevel += 1;
//}
//if(input.GetMouseButtonState(5))
//{
// m_zoomLevel -= 1;
//}
// Sets the camera to always be in the center of the screen where the player is
newPosX = player.GetPosition().x - (m_screenWidth / 2) +
((player.GetWidth() / 2) * (player.GetScale() * m_zoomLevel));
newPosY = player.GetPosition().y - (m_screenHeight / 2) +
((player.GetHeight() / 2) * (player.GetScale() * m_zoomLevel));
m_posX = Lerp(m_posX, newPosX, 0.07f);
m_posY = Lerp(m_posY, newPosY, 0.07f);
//Restrict to the level
if(m_posX >= (level.GetMapSize()*32) - (m_screenWidth))
{
m_posX = (level.GetMapSize()*32) - (m_screenWidth);
}
if(m_posX <= 0)
{
m_posX = 0;
}
if(m_posY >= (level.GetMapSize()*32) - (m_screenHeight))
{
m_posY = (level.GetMapSize()*32) - (m_screenHeight);
}
if(m_posY <= 0)
{
m_posY = 0;
}
Camera::Update(dt);
}