当前位置: 首页>>代码示例>>C++>>正文


C++ ParticleSystem::AddParticle方法代码示例

本文整理汇总了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);
}
开发者ID:pokelege,项目名称:GeometryWars,代码行数:18,代码来源:EnemyShip.cpp

示例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;
			}
		}    
	}
}
开发者ID:danepowell,项目名称:openhaptics,代码行数:99,代码来源:main.cpp


注:本文中的ParticleSystem::AddParticle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。