void World::update(sf::Time dt)
{
	// Scroll the world, reset player velocity
	mWorldView.move(0.f, mScrollSpeed * dt.asSeconds() * mScrollSpeedCompensation);	

	FOREACH(Aircraft* a, mPlayerAircrafts)
		a->setVelocity(0.f, 0.f);

	// Setup commands to destroy entities, and guide missiles
	destroyEntitiesOutsideView();
	guideMissiles();

	// Forward commands to scene graph, adapt velocity (scrolling, diagonal correction)
	while (!mCommandQueue.isEmpty())
		mSceneGraph.onCommand(mCommandQueue.pop(), dt);

	adaptPlayerVelocity();

	// Collision detection and response (may destroy entities)
	handleCollisions();

	// Remove aircrafts that were destroyed (World::removeWrecks() only destroys the entities, not the pointers in mPlayerAircraft)
	auto firstToRemove = std::remove_if(mPlayerAircrafts.begin(), mPlayerAircrafts.end(), std::mem_fn(&Aircraft::isMarkedForRemoval));
	mPlayerAircrafts.erase(firstToRemove, mPlayerAircrafts.end());

	// Remove all destroyed entities, create new ones
	mSceneGraph.removeWrecks();
	spawnEnemies();

	// Regular update step, adapt position (correct if outside view)
	mSceneGraph.update(dt, mCommandQueue);
	adaptPlayerPosition();

	updateSounds();
}
예제 #2
0
void World::update(sf::Time dt)
{
	// Scroll the world, reset player velocity
	mWorldView.move(0.f, mScrollSpeed * dt.asSeconds());	
	mPlayerAircraft->setVelocity(0.f, 0.f);

	// Setup commands to destroy entities, and guide missiles
	destroyEntitiesOutsideView();
	guideMissiles();

	// Forward commands to scene graph, adapt velocity (scrolling, diagonal correction)
	while (!mCommandQueue.isEmpty())
		mSceneGraph.onCommand(mCommandQueue.pop(), dt);
	adaptPlayerVelocity();

	// Collision detection and response (may destroy entities)
	handleCollisions();

	// Remove all destroyed entities, create new ones
	mSceneGraph.removeWrecks();
	spawnEnemies();

	// Regular update step, adapt position (correct if outside view)
	mSceneGraph.update(dt, mCommandQueue);
	adaptPlayerPosition();

	updateSounds();
}
예제 #3
0
void World::update(sf::Time dt)
{
	/*FOREACH(PlayerBat* a, mPlayerBats)
	a->setVelocity(0.f, 0.f);*/

	// Setup commands to destroy entities
	destroyEntitiesOutsideView();

	// Forward commands to scene graph, adapt velocity (diagonal correction)
	while (!mCommandQueue.isEmpty())
		mSceneGraph.onCommand(mCommandQueue.pop(), dt);

	adaptPlayerVelocity();

	// Collision detection and response (may destroy entities)
	handleCollisions();

	// Remove PlayerBats that were destroyed (World::removeWrecks() only destroys the entities, not the pointers in mPlayerBat)
	auto firstToRemove = std::remove_if(mPlayerBats.begin(), mPlayerBats.end(), std::mem_fn(&PlayerBat::isMarkedForRemoval));
	mPlayerBats.erase(firstToRemove, mPlayerBats.end());

	// Remove all destroyed entities
	mSceneGraph.removeWrecks();

	// Regular update step, adapt position (correct if outside view)
	mSceneGraph.update(dt, mCommandQueue);
	adaptPlayerPosition();

	updateSounds();
}
예제 #4
0
void World::update(sf::Time dt)
{
	// Reset player velocity
	mPlayer->setVelocity(0.f, 0.f);

	// Remove useless entities
	destroyEntitiesOutsideView();

	// Update quadtree
	checkForCollision();

	// Update Invaders command: Adapt Movements 
	mInvaders.updateCommand(mCommandQueue);

	// Forward commands to scene graph
	while (!mCommandQueue.isEmpty())
		mSceneGraph.onCommand(mCommandQueue.pop());

	// Update Invasers: Control enemy fires, speed and check end of the game
	mInvaders.update(*mPlayer, mDeadLine, mIsGameEnded, mChangeSpeed);

	// Collision detection and response (may destroy entities)
	handleCollisions();

	// Check if Player Dead
	if (mPlayerFactory.update(dt, mCommandQueue))
		return;

	mBossFactory.update(dt);

	mSceneGraph.removeWrecks();

	updateSpawns();

	// Regular update step
	mSceneGraph.update(dt, mCommandQueue);

	// Adapt position (correct if outside view)
	adaptPlayerPosition();

	updateSounds();
}
예제 #5
0
void
World::update( sf::Time dt ) {
    mWorldView.move(
        0.0f,
        mScrollSpeed * dt.asSeconds() * mScrollSpeedCompensation
    );

    for ( Aircraft* a : mPlayerAircrafts ) {
        a->SetVelocity( 0.0f, 0.0f );
    }

    destroyEntitiesOutsideView();
    guideMissiles();

    while ( !mCommandQueue.isEmpty() ) {
        mSceneGraph.OnCommand( mCommandQueue.pop(), dt );
    }

    adaptPlayerVelocity();
    handleCollisions();

    // Remove aircrafts that were destroyed
    // (World::removeWrecks() only destroys the entities,
    // not the pointers in mPlayerAircrafts)
    auto firstToRemove = std::remove_if(
        mPlayerAircrafts.begin(),
        mPlayerAircrafts.end(),
        std::mem_fn( &Aircraft::IsMarkedForRemoval )
    );
    mPlayerAircrafts.erase( firstToRemove, mPlayerAircrafts.end() );

    mSceneGraph.RemoveWrecks();
    spawnEnemies();

    mSceneGraph.Update( dt, mCommandQueue );
    adaptPlayerPosition();

    updateSounds();
}
예제 #6
0
void World::update(sf::Time dt)
{
	// Scroll the world, reset player velocity
	mWorldView.move(0.f, mScrollSpeed * dt.asSeconds());	
	mPlayerSpaceship->setVelocity(0.f, 0.f);

	// Check for delete enemies
	destroyEntitiesOutsideView();


	// Forward commands to scene graph, adapt velocity (scrolling, diagonal correction)
	while (!mCommandQueue.isEmpty())
		mSceneGraph.onCommand(mCommandQueue.pop(), dt);
	adaptPlayerVelocity();
	// Handle our collision.
	handleCollisions();

	// Remove all destroyed entities, and create new.
	mSceneGraph.removeWrecks();
	// Templates for add new Enemies.
	addNewEnemies(dt);
	spawnEnemies();
	// Check, for edding new world texture.
	updateWorldBounds();


	// Regular update step, adapt position (correct if outside view)
	mSceneGraph.update(dt, mCommandQueue);
	adaptPlayerPosition();
	// Update Points and Health.
	updateText(dt);

	mBattlifieldBounds.setPosition(getBattlefieldBounds().left, getBattlefieldBounds().top);
	// Update ScrollSpeed
	mScrollSpeed -= ScrollSpeedAccelerate * dt.asSeconds();
}