Example #1
0
// ZZZ: split out from update_world()'s loop.
static int
update_world_elements_one_tick()
{
	if (m1_solo_player_in_terminal()) 
	{
		update_m1_solo_player_in_terminal(GameQueue);
	} 
	else
	{
		L_Call_Idle();
		
		update_lights();
		update_medias();
		update_platforms();
		
		update_control_panels(); // don't put after update_players
		update_players(GameQueue, false);
		move_projectiles();
		move_monsters();
		update_effects();
		recreate_objects();
		
		handle_random_sound_image();
		animate_scenery();
		
		// LP additions:
		if (film_profile.animate_items)
		{
			animate_items();
		}
		
		AnimTxtr_Update();
		ChaseCam_Update();
		motion_sensor_scan();
		check_m1_exploration();
		
#if !defined(DISABLE_NETWORKING)
		update_net_game();
#endif // !defined(DISABLE_NETWORKING)
	}

        if(check_level_change()) 
        {
                return kUpdateChangeLevel;
        }

#if !defined(DISABLE_NETWORKING)
        if(game_is_over())
        {
                return kUpdateGameOver;
        }
#endif // !defined(DISABLE_NETWORKING)

        dynamic_world->tick_count+= 1;
        dynamic_world->game_information.game_time_remaining-= 1;
        
        return kUpdateNormalCompletion;
}
void GameScene::update(float dt)
{
    for (Entity* d : decorations_)
    {
        d->update(dt);
    }

    for (Entity* p : platforms_)
    {
        p->update(dt);
    }

    for (Entity* g : goalflags_)
    {
        g->update(dt);
    }

    update_effects(dt);

    for (Entity* c : collectibles_)
    {
        c->update(dt);

        sf::FloatRect bbox(c->collision_area());
        if (!c->animation().hidden() &&
            bbox.Intersects(player_.collision_area()))
        {
            explode(c,true);
            collectsnd_.Play();
        }
    }

    update_player(dt);

    bool out_of_bounds = true;
    for (Entity* p : platforms_)
    {
        if (vector_magnitude(
            p->position() - player_.position())
            < 1000)
        {
            out_of_bounds = false;
        }
    }

    if (out_of_bounds)
    {
        init_world();
    }

    update_camera(dt);
}