本文整理汇总了C++中EntityManager::getInstance方法的典型用法代码示例。如果您正苦于以下问题:C++ EntityManager::getInstance方法的具体用法?C++ EntityManager::getInstance怎么用?C++ EntityManager::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityManager
的用法示例。
在下文中一共展示了EntityManager::getInstance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
MathGame()
{
//Create the manager singleton by calling it
manager->getInstance()->SetWindowSize(window_size); //set the window size
manager->getInstance()->SetLives(3); //set the life count
manager->getInstance()->Create(0,Vector3D(100,100,0),1); //Create player character
manager->getInstance()->Create(2,Vector3D(300,300,0),0); //Create scatter pill
manager->getInstance()->Create(3,Vector3D(100,150,0),0); //Create delete cube
manager->getInstance()->Create(5,Vector3D(600,700,0),0); //Create speed diamond
manager->getInstance()->Create(1,Vector3D(window_size-50,window_size-50,0),3); //Create an AI opponent
timer = 0; //create the timer for adding AI opponents
endTimer = 0; //create the timer for ending the game
pillTimer = 0;
dTimer = 0;
sTimer = 0;
diamTimer = 0;
counter = 0; //count the number of AI opponents in the game
spawnCount = 8;
srand (time(NULL));
}
示例2: Update_Model
void Update_Model()
{
//increase the timers
timer += elapsed_time;
if (!manager->getInstance()->pill)
{
pillTimer += elapsed_time;
if (pillTimer >= 20)
{
pillTimer = 0;
Scalar x,y;
x = rand()%(window_size+1);
y = rand()%(window_size+1);
manager->getInstance()->Create(2,Vector3D(x,y,0),0); //Create scatter pill
}
}
if (!manager->getInstance()->dCube)
{
dTimer += elapsed_time;
if (dTimer >= 10)
{
dTimer = 0;
Scalar x,y;
x = rand()%(window_size+1);
y = rand()%(window_size+1);
manager->getInstance()->Create(3,Vector3D(x,y,0),0); //Create delete cube
}
}
if (!manager->getInstance()->sCube)
{
sTimer += elapsed_time;
if (sTimer >= 30)
{
sTimer = 0;
Scalar x,y;
x = rand()%(window_size+1);
y = rand()%(window_size+1);
manager->getInstance()->Create(4,Vector3D(x,y,0),0); //Create super cube
}
}
if (!manager->getInstance()->diam)
{
diamTimer += elapsed_time;
if (diamTimer >= 30)
{
diamTimer = 0;
Scalar x,y;
x = rand()%(window_size+1);
y = rand()%(window_size+1);
manager->getInstance()->Create(5,Vector3D(x,y,0),0); //Create speed diamond
}
}
if (timer >= spawnCount && counter < 8) //Every eight seconds, until we have three enemies, create another character
{
spawnCount -= 0.1;
timer = 0;
//Randomly generate the position
Scalar x,y,orient;
x = rand()%(window_size+1);
y = rand()%(window_size+1);
orient = rand()%(360+1);
orient *= Math::PI/180;
orient -= Math::PI;
manager->getInstance()->Create(1,Vector3D(x,y,0),orient);
}
if (counter >= 10)
manager->getInstance()->fastEnemies = true;
else
manager->getInstance()->fastEnemies = false;
manager->getInstance()->Update(elapsed_time); //Update the game
if(manager->getInstance()->numDeleted != 0)
{
counter -= manager->getInstance()->numDeleted;
manager->getInstance()->numDeleted = 0;
}
if(manager->getInstance()->numCreated != 0)
{
counter += manager->getInstance()->numCreated;
manager->getInstance()->numCreated = 0;
}
if (manager->getInstance()->Lives() < 0) //If you run out of lives, game over
game_over = true;
//.........这里部分代码省略.........
示例3: Render_Model
void Render_Model()
{
manager->getInstance()->Render(); //Render the models
}