Example #1
0
int main(int argc, char* argv[])
{
    SetSphereDirectory();

    // load the configuration settings, then save it for future reference
    SPHERECONFIG config;
    LoadSphereConfiguration(&config);

    for (int i = 0; i < 4; i++)
    {
        SetPlayerConfig(i,
                KeyStringToKeyCode(config.player_configurations[i].key_menu_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_up_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_down_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_left_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_right_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_a_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_b_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_x_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_y_str.c_str()),
                config.player_configurations[i].keyboard_input_allowed,
                config.player_configurations[i].joypad_input_allowed);
    }

	SetGlobalConfig(config.language, config.sound, config.allow_networking);
    SaveSphereConfig(&config, (GetSphereDirectory() + "/engine.ini").c_str());

    // initialize screenshot directory
    std::string sphere_directory;
    char screenshot_directory[512];
    GetDirectory(sphere_directory);
    sprintf(screenshot_directory, "%s/screenshots", sphere_directory.c_str());
    SetScreenshotDirectory(screenshot_directory);

    // initialize video subsystem
    if (InitVideo(&config) == false)
    {
        printf("Video subsystem could not be initialized...\n");
        return 0;
    }

    // initialize input
    InitInput();

    // initialize audio
    if (!InitAudio(&config))
    {
        printf("Sound could not be initialized...\n");
    }

    atexit(CloseVideo);
    atexit(CloseAudio);

    RunSphere(argc, const_cast<const char **>(argv));

    return 0;
}
Example #2
0
int main(int argc, const char* argv[])
{
    SetSphereDirectory();

    // load the configuration settings, then save it for future reference
    SPHERECONFIG config;
    LoadSphereConfiguration(&config);

    for (int i = 0; i < 4; i++)
    {
      SetPlayerConfig(i,
                KeyStringToKeyCode(config.player_configurations[i].key_menu_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_up_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_down_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_left_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_right_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_a_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_b_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_x_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_y_str.c_str()),
                config.player_configurations[i].keyboard_input_allowed,
                config.player_configurations[i].joypad_input_allowed);
    }

	SetGlobalConfig(config.language, config.sound, config.allow_networking);
    SaveSphereConfig(&config, (GetSphereDirectory() + "/engine.ini").c_str());

    original_directory = getcwd(NULL, 0);
    char* env_data_dir = getenv("SPHERE_DATA_DIR");

    if (env_data_dir != NULL)
        strcpy(unix_data_dir, env_data_dir);

    if (getopt(argc, const_cast<char**>(argv), "d:") == 'd')
        strcpy(unix_data_dir, optarg);

    chdir(unix_data_dir);
    srand((unsigned)GetTime());

    // initialize video subsystem
    if (InitVideo(&config) == false)
    {
        printf("Video subsystem could not be initialized...\n");
        return 0;
    }

    // initialize input
    InitializeInput();

    // initialize audio
    if (!InitAudio(&config))
    {
        printf("Sound could not be initialized...\n");
    }

    atexit(CloseVideo);
    atexit(CloseAudio);

    RunSphere(argc, argv);

}