本文整理汇总了C++中Entities::AddEntity方法的典型用法代码示例。如果您正苦于以下问题:C++ Entities::AddEntity方法的具体用法?C++ Entities::AddEntity怎么用?C++ Entities::AddEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entities
的用法示例。
在下文中一共展示了Entities::AddEntity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Mouse
//=======================================================================
// Mouse Function
//=======================================================================
void Mouse(int button, int state, int x, int y)
{
y = glutGet(GLUT_WINDOW_HEIGHT) - y;
if(button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
{
Vector dirVector = Vector(x,y) - Vector(WIDTH/2, HEIGHT/2);
float dirVectorMag = sqrtf((dirVector.x * dirVector.x) + (dirVector.y * dirVector.y));
Vector normalizedDir = dirVector/dirVectorMag;
Entity *bullet = new Entity(WIDTH/2, HEIGHT/2, normalizedDir, BULLET);
bulletsList.AddEntity(bullet);
Vector shipUp(0,1);
float dotProduct = (dirVector.x * shipUp.x) + (dirVector.y * shipUp.y);
float cosAngle = dotProduct / (shipUp.Magnitude() * dirVector.Magnitude()) ;
float angle = acos(cosAngle) * 180.f / PI;
x > WIDTH/2 ? shipRotation = -angle : shipRotation = angle;
}
}
示例2: SpawnEnemies
//=======================================================================
// Random Enemy Location Function
//=======================================================================
void SpawnEnemies(int)
{
Vector startlocation = GetRandomPosOffScreen();
int level;
(((int)startlocation.x + (int)startlocation.y) % 2) == 0 ? level = 0 : level = 1;
Enemy *enemy = new Enemy(startlocation.x, startlocation.y, Vector(), ENEMY, startlocation, level);
EnemyList.AddEntity(enemy);
glutTimerFunc(1000.0/Difficulty, SpawnEnemies, 0);
}