本文整理汇总了C++中ParticleSystem::AddParticle方法的典型用法代码示例。如果您正苦于以下问题:C++ ParticleSystem::AddParticle方法的具体用法?C++ ParticleSystem::AddParticle怎么用?C++ ParticleSystem::AddParticle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParticleSystem
的用法示例。
在下文中一共展示了ParticleSystem::AddParticle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
bool EnemyShip::Update(const float& dt, bool& warp, ParticleSystem& Psystem, BulletSystem& Bsystem, Spaceship* target, Walls& walls)
{
changeTarget(target);
turret.update(dt, shipPosition, Bsystem, (rand.RandomFloat() < 0.1));
outofBoundsCheck(Psystem, warp);
changeVelocity(dt, Psystem);
Vector2 collision = walls.getCollisionVelocity(shipPosition, velocity);
if (Engine::LengthSquared(collision) != 0)
{
Psystem.AddParticle(new COLLISIONPARTICLE);
}
velocity = velocity + collision;
shipPosition = shipPosition + velocity;
return (life > 0);
}
示例2: HandleMouseButton
/*
Function: HandleMouseButton
Usage: HandleMouseButton(button, state, x, y);
---------------------------------------------------------------------------
mouse press/release handler
left button:
simulating: pull at particle
designing: add particle/constraint
middle button: unused
right button: unused (mapped to pull-down menu)
*/
void HandleMouseButton(int button, int state, int x, int y)
{
int part; // index of a particle
if (mDesign)
{
if (button == GLUT_LEFT_BUTTON)
{
switch (state)
{
case GLUT_DOWN:
switch (mMode)
{
case designMode_Particle:
mPS.AddParticle(x,y);
break;
case designMode_Nail:
if ((part = mPS.GetClosestParticle(x, y)) != -1)
mPS.AddNailConstraint(part);
break;
case designMode_Spring:
if ((part = mPS.GetClosestParticle(x, y)) != -1)
mCurrSpringConstraint = mPS.AddSpringConstraint(part, part);
break;
}
break;
case GLUT_UP:
switch (mMode)
{
case designMode_Spring:
if (mCurrSpringConstraint != NULL)
{
if ((part = mPS.GetClosestParticle(x, y)) != -1)
{
mCurrSpringConstraint->SetParticle(part);
if (mCurrSpringConstraint->ParticlesAreValid())
{
// keep the constraint
}
else
{
mPS.DeleteConstraint(mCurrSpringConstraint);
}
}
else
{
mPS.DeleteConstraint(mCurrSpringConstraint);
}
mCurrSpringConstraint = NULL;
}
break;
}
break;
}
}
else if (button == GLUT_MIDDLE_BUTTON)
{
switch (state)
{
case GLUT_DOWN:
break;
case GLUT_UP:
break;
}
}
}
else
{
if (button == GLUT_LEFT_BUTTON)
{
switch (state)
{
case GLUT_DOWN:
mPS.ActivateMouseSpring(x, y);
break;
case GLUT_UP:
mPS.DeactivateMouseSpring();
break;
}
}
}
}