Exemplo n.º 1
0
int main(int argc,char *argv[])
try
{
	sge::parse::json::object const config_file =
		insula::json::config_wrapper(
			{"user_config.json"},
			argc,
			argv);

	insula::machine m(
		config_file);

	insula::scoped_machine scope(
		m);

	sge::time::timer frame_timer(
		sge::time::second(1));
	while (m.running())
		m.tick(
			frame_timer.reset());
}
catch (fcppt::exception const &e)
{
	fcppt::io::cerr << e.string() << FCPPT_TEXT('\n');
	return EXIT_FAILURE;
}
catch(std::exception const &e)
{
	std::cerr << e.what() << '\n';
	return EXIT_FAILURE;
}
Exemplo n.º 2
0
int
main()
try
{
    sge::systems::instance<
    boost::mpl::vector2<
    sge::systems::with_audio_loader,
        sge::systems::with_audio_player
        >
        > const sys(
            sge::systems::make_list
            (
                sge::systems::audio_player_default()
            )
            (
                sge::systems::audio_loader(
                    sge::media::optional_extension_set(
    sge::media::extension_set{
        sge::media::extension(
            FCPPT_TEXT("wav")
        )
    }
                    )
                )
            )
        );

    sge::audio::file_unique_ptr const file(
        sge::audio::load_exn(
            sys.audio_loader(),
            sge::config::media_path()
            /	FCPPT_TEXT("sounds")
            / FCPPT_TEXT("ding.wav")
        )
    );

    sge::audio::sound::positional_unique_ptr const sound(
        sys.audio_player().create_positional_stream(
            *file,
    sge::audio::sound::positional_parameters{
        sge::audio::position{
            fcppt::math::vector::null<
            sge::audio::vector
            >()
        }
    }
        )
    );

    sound->play(
        sge::audio::sound::repeat::loop
    );

    sge::timer::basic<
    sge::timer::clocks::standard
    > frame_timer(
        sge::timer::parameters<
        sge::timer::clocks::standard
        >(
            std::chrono::seconds(
                1
            )
        )
    );

    sge::audio::scalar const rpm(
        fcppt::literal<
        sge::audio::scalar
        >(
            1
        )
    );

    sge::audio::scalar const speed(
        fcppt::math::twopi<
        sge::audio::scalar
        >()
        *
        rpm
    );

    for(;;)
    {
        sge::audio::scalar const angle(
            sge::timer::elapsed_fractional<
            sge::audio::scalar
            >(
                frame_timer
            )
            *
            speed
        );

        sound->position(
            sge::audio::vector2_to_vector(
        sge::audio::vector2{
            std::sin(
                angle
            ),
            std::cos(
                angle
            )
        }
            )
        );

        sound->update();
    }
}
catch(
        fcppt::exception const &_error
    )
{
    fcppt::io::cerr()
            << _error.string()
            << FCPPT_TEXT('\n');

    return
        EXIT_FAILURE;
}
catch(
        std::exception const &_error
    )
{
    std::cerr
            << _error.what()
            << '\n';

    return
        EXIT_FAILURE;
}