Beispiel #1
0
void Sound_reloadTrack(void) {
  char *song;
  char *path;
	scripting_GetGlobal("settings", "current_track", NULL);
  scripting_GetStringResult(&song);
  fprintf(stderr, "[sound] loading song %s\n", song);
  path = getPath( PATH_MUSIC, song );
  scripting_StringResult_Free(song);
  if(path == NULL) {
    fprintf(stderr, "[sound] can't find song...exiting\n");
    nebu_assert(0); exit(1); // TODO: handle missing song somewhere else
  }
  Sound_load(path);
  Sound_play();

  free(path);
}
Beispiel #2
0
void Sound_reloadTrack(void) {
  char *song;
  char *path;
	scripting_GetGlobal("settings", "current_track", NULL);
  scripting_GetStringResult(&song);
  // TODO: fix the song loading
  free(song);

  song = "song_revenge_of_cats.it";
  fprintf(stderr, "[sound] loading song %s\n", song);
  path = getPath( PATH_MUSIC, song );
//  free(song);
  if(path == NULL) {
    fprintf(stderr, "[sound] can't find song...exiting\n");
    exit(1); // FIXME: handle missing song somewhere else
  }
  Sound_load(path);
  Sound_play();

  free(path);
}
Beispiel #3
0
bool System_init(int width, int height) {
    if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) < 0) {
        log_error("SDL Init failed");
        return false;
    }

    if (!SDL_SetHint(SDL_HINT_RENDER_VSYNC, "1")) {
        log_error("SDL Set VSYNC failed");
    }

    if (!(IMG_Init(IMG_INIT_PNG) & IMG_INIT_PNG)) {
        log_error("IMG Init failed");
        return false;
    }

    if (TTF_Init() < 0) {
        log_error("TTF Init failed");
        return false;
    }

    if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0) {
        log_error("Mix_OpenAudio failed");
        return false;
    }

    window = System_createWindow(width, height);
    if (window == NULL) {
        return false;
    }

    renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
    SDL_Rect viewport = {0, 0, width, height};
    SDL_RenderSetViewport(renderer, &viewport);

    ScoreBar_create();
    Sound_load();

    return true;
}