Ejemplo n.º 1
0
void Bullet::Update()
{
	Particle::Update();
	Animation_CurrentFrame = Animation_CurrentFrame % 2;

	std::list<Plane*> *curPlanes = Game->GetPlaneObjects();
	for( std::list<Plane*>::iterator ptr = curPlanes->begin(); ptr != curPlanes->end(); ptr++ )
	{
		GameObject* gObj = (GameObject*)(*ptr);
		Plane* pObj = (Plane*)(*ptr);
		if( pObj != Owner && (Game->Rules_FriendlyFire || pObj->Team != ((Plane*)Owner)->Team) )
		{
			if( pObj->State == STATE_FLYING || pObj->State == STATE_STALLED || pObj->State == STATE_SHOOT )
			{
				 if( Position->DistanceTo( pObj->Position ) < 24.0 )
				 {
					 pObj->SetState( STATE_HIT );
					 pObj->LastHitBy = (Plane*)Owner;
					 ((Plane*)Owner)->Score++;
					 ForRemoval = true;
					 break;
				 }
			}
		}
	}
}
Ejemplo n.º 2
0
void GameStage::Update()
{
	GameObject* gObj;
	Plane* pObj;

	int ObjIdx = 0;
	ObjectsToRemove.clear();
	for( std::vector<GameObject*>::iterator ptr = Objects.begin(); ptr != Objects.end(); ptr++ )
	{
		gObj = (GameObject*)(*ptr);
		gObj->Update();
		if( gObj->ForRemoval )
		{
			ObjectsToRemove.push_back( ObjIdx );
		}

		if( Rules_HasGround && gObj->Position->Y >= (Framework::SystemFramework->GetDisplayHeight() / graphicsMultiplier) - 32 )
		{
			pObj = dynamic_cast<Plane*>(*ptr);
			if( pObj != 0 )
			{
				if( pObj->State != STATE_EXPLODING && pObj->State != STATE_EXPLODED )
				{
					pObj->LastHitBy = 0;
					pObj->SetState( STATE_EXPLODING );
				}
			} else {
				gObj->ForRemoval = true;
				ObjectsToRemove.push_back( ObjIdx );
			}
		}
		ObjIdx++;
	}

	while( (int)ObjectsToRemove.size() > 0 )
	{
		Objects.erase( Objects.begin() + ObjectsToRemove.back() );
		ObjectsToRemove.pop_back();
	}

	bool AddedObjects = false;
	while( (int)ObjectsToAdd.size() > 0 )
	{
		Objects.push_back( ObjectsToAdd.front() );
		ObjectsToAdd.pop_front();
		AddedObjects = true;
	}
	if( AddedObjects )
	{
		SortObjectsList();
	}


	// Only process game rules if we're the active stage (ie, highscores will just update planes
	if( Framework::SystemFramework->ProgramStages->Current() == this )
	{
		UpdateByRules();
	}

}