Exemple #1
0
void
BackgroundMusic (void)
{
#ifdef WITH_SOUND
  {
    int new_track = -1;
    Mix_VolumeMusic (96);
	
    if (map.rooms[player_room].s_dist <= 15)
      new_track = BGM_INNER;
	
    if (bgm_track == BGM_MIDWAY
        && map.rooms[player_room].s_dist <= 30
        && map.rooms[player_room].s_dist >= 10)
      new_track = BGM_MIDWAY;
      
    if (bgm_track == BGM_OUTER
        && map.rooms[player_room].s_dist <= 45
        && map.rooms[player_room].s_dist >= 25)
      new_track = BGM_OUTER;
	
    if (new_track == -1)
      {
        if (map.rooms[player_room].s_dist <= 30
            && map.rooms[player_room].s_dist >= 16)
          new_track = BGM_MIDWAY;
        else if (map.rooms[player_room].s_dist <= 39
                 && map.rooms[player_room].s_dist >= 31)
          new_track = BGM_OUTER;
        else if (map.rooms[player_room].s_dist >= 40)
          new_track = BGM_EDGE;
      }
	
    if (map.rooms[player_room].room_type == ROOM_ART_CHALLENGE)
      new_track = BGM_ART_CHALLENGE;
	
    if (artifacts[ART_CURSED_SEAL])
      new_track = BGM_CURSED_SEAL;
	
    if (map.rooms[player_room].room_type == ROOM_BOSS)
      {
        if (boss_fight_mode == BSTA_FIGHTING)
          {
            if (current_boss == BOSS_FINAL
                && player.has_agate_knife)
              {
                if (boss_lives <= 1)
                  new_track = BGM_FINAL_CRITICAL;
                else
                  new_track = BGM_FINAL_AGATE;
              }
            else
              {
                new_track = BGM_MERIDIAN + current_boss;
              }
            Mix_VolumeMusic (128);
          }
        else
          new_track = -1;
      }
	
    if (player_room == 0
        && current_boss == BOSS_FINAL
        && boss_fight_mode >= BSTA_DYING) 
      new_track = BGM_FINAL_DEAD;
	
    if (new_track == bgm_track)
      return;

    if (bgm_track != -1)
      {
        Mix_HaltMusic ();
        Mix_FreeMusic (bgm_music);
        bgm_music = NULL;
      }

    if (new_track != -1)
      PlayBackgroundMusic (new_track);
      
    bgm_track = new_track;
  }
#endif /*WITH_SOUND */
}
Exemple #2
0
// 初期化
// 成功したときは0を、失敗したときは-1を返す。
int Game::Initialize(void) {
    // 初期化
    if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER) < 0) {
        fprintf(stderr, "SDLの初期化に失敗しました:%s\n", SDL_GetError());
        return -1;
    }
    if (TTF_Init() < 0) {
        fprintf(stderr, "TTFの初期化に失敗しました:%s\n", TTF_GetError());
        return -1;
    }
    window = SDL_CreateWindow("パズルゲーム", SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED,WINDOW_WIDE,WINDOW_HIGH,0);
    screen = SDL_GetWindowSurface(window);
    if (screen == NULL) {
        fprintf(stderr, "画面の初期化に失敗しました:%s\n", SDL_GetError());
        Finalize();
        return -1;
    }
    
    /* 画像を読み込む */
    section_image = IMG_Load("section_image.png");
    if (section_image == NULL) {
        fprintf(stderr, "画像の読み込みに失敗しました:%s\n", SDL_GetError());
        Finalize();
        return -1;
    }
    section_image_02 = IMG_Load("section_image_02.png");
    if (section_image_02 == NULL) {
        fprintf(stderr, "画像の読み込みに失敗しました:%s\n", SDL_GetError());
        Finalize();
        return -1;
    }
    block_image = IMG_Load("block_image.png");
    if (block_image == NULL) {
        fprintf(stderr, "画像の読み込みに失敗しました:%s\n", SDL_GetError());
        Finalize();
        return -1;
    }
    particle_image = IMG_Load("particle_image.png");
    if (particle_image == NULL) {
        fprintf(stderr, "画像の読み込みに失敗しました:%s\n", SDL_GetError());
        Finalize();
        return -1;
    }
    
    // フォント読み込む
    font = TTF_OpenFont("AquaKana.ttc", 24);
    if (font == NULL) {
        fprintf(stderr, "fontの取得に失敗しました:%s\n", SDL_GetError());
        Finalize();
        return -1;
    }
    big_font = TTF_OpenFont("AquaKana.ttc", 36);
    if (big_font == NULL) {
        fprintf(stderr, "big_fontの取得に失敗しました:%s\n", SDL_GetError());
        Finalize();
        return -1;
    }
    
    // SDL_Mixerオープン
    Mix_OpenAudio(22050,AUDIO_S16,2,4096);
    // BGM読み込み
    music_main = Mix_LoadMUS("music_main.mp3");
    if (music_main == NULL) {
        fprintf(stderr, "music_mainの取得に失敗しました:%s\n", SDL_GetError());
        Finalize();
        return -1;
    }
    // ブロック破壊音読み込み
    music_break = Mix_LoadWAV("music_break.mp3");
    if (music_break == NULL) {
        fprintf(stderr, "music_breakの取得に失敗しました:%s\n", SDL_GetError());
        Finalize();
        return -1;
    }
    
    // 音量調節
    Mix_VolumeMusic(10);
    Mix_Volume(-1,5);
    
    
    return 0;
}
Exemple #3
0
/*Cette fonction sert de page d'accueil du jeu du Pendu, elle fait appel à la fonction jouer_Pendu quand l'utilisateur
  appuie sur "Entrer", et à la fin elle récupère l'indice du gagnant et le renvoie à son tour*/
int Accueil_Pendu(SDL_Surface *ecran, char *j1, char *j2) {
  //Déclaration des variables locales nécessaires pour la fonction.
  SDL_Surface *texte1 = NULL, *texte2 = NULL, *pendu = NULL;
  SDL_Rect positiontexte1, positiontexte2, positionpendu;
  SDL_Event event;
  TTF_Font *police1 = NULL, *police2 = NULL;
  SDL_Color couleurNoire = {0, 0, 0, 0}, couleurBlanche = {255, 255, 255, 0};
  int continuer = 1, gagnant;
  Mix_Music *musique; //Création d'un pointeur de type Mix_Music
  Mix_VolumeMusic(MIX_MAX_VOLUME);
  musique = Mix_LoadMUS("../Music/Mini-jeux/pendu.ogg"); //Chargement de la musique
  Mix_PlayMusic(musique, -1); //Jouer infiniment la musique

  //Chargement de l'image du pendu
  pendu = IMG_Load("../images/Mini-jeux/Pendu10.png");

  //Chargement de la police
  police1 = TTF_OpenFont("../Police/chata.ttf", 65);
  police2 = TTF_OpenFont("../Police/chata.ttf", 25);

  //Initialisation du texte
  texte1 = TTF_RenderText_Shaded(police1, "Le Pendu", couleurNoire, couleurBlanche);
  texte2 = TTF_RenderText_Shaded(police2, "Appuyer sur entrer pour commencer", couleurNoire, couleurBlanche);

  SDL_SetColorKey(texte1, SDL_SRCCOLORKEY, SDL_MapRGB(texte1->format, 255, 255, 255));
  SDL_SetColorKey(texte2, SDL_SRCCOLORKEY, SDL_MapRGB(texte2->format, 255, 255, 255));

  //Remplissage de l'écran principal avec la couleur blanche
  SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 0, 200, 100));

  //Initialisation des positions des différentes surfaces et textes
  positiontexte1.x = (ecran->w - texte1->w) / 2;
  positiontexte1.y = 0;
  positiontexte2.x = (ecran->w - texte2->w) / 2;
  positiontexte2.y = 250 + (ecran->h - texte2->h) / 2;
  positionpendu.x = (ecran->w / 2) - (pendu->w / 2);
  positionpendu.y = (ecran->h / 2) - (pendu->h / 2);

  //Remplissage de l'écran principal avec la couleur blanche
  SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 0, 200, 100));

  //Blit du texte de la page d'accueil
  SDL_BlitSurface(texte1, NULL, ecran, &positiontexte1);
  SDL_BlitSurface(texte2, NULL, ecran, &positiontexte2);

  //Blit de l'image du pendu
  SDL_BlitSurface(pendu, NULL, ecran, &positionpendu);

  //Mise à jour de l'écran
  SDL_Flip(ecran);

  /*Une boucle infine afin de maintenir l'affichage et quitter le programme quand l'utilisateur ferme la fenêtre*/
  while (continuer) {
    SDL_PollEvent(&event);
    switch(event.type) {
    case SDL_QUIT:
      continuer = 0;
      break;
    //En cas d'apuui sur un bouton
    case SDL_KEYDOWN :
      //S'il s'agit du bouton "Entrer", appeler la fonction joueur_Pendu
      if(event.key.keysym.sym == SDLK_RETURN) gagnant = jouer_Pendu(ecran,j1,j2);
      continuer = 0;
      break;
    default: break;
    }
  }

  //Libération de la mémoire occupée par les surfaces et les polices et arrêt de la SDL
  TTF_CloseFont(police1);
  TTF_CloseFont(police2);
  SDL_FreeSurface(pendu);
  SDL_FreeSurface(texte1);
  SDL_FreeSurface(texte2);
  Mix_FreeMusic(musique); //Libération de la musique

  return gagnant;
}
Exemple #4
0
//
// SetVolume
//
static void SetVolume(int volume)
{
   Mix_VolumeMusic((volume * 128) / 15);
}
Exemple #5
0
//
// ResumeSong
//
static void ResumeSong()
{
   Mix_VolumeMusic(paused_midi_volume);
}
void SoundManager::music_change_volume(const float vol)
{
    Mix_VolumeMusic(MIX_MAX_VOLUME * vol);
    _music_volume = vol;
}
Exemple #7
0
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// * Sets the volume
void CSound::SetVolume(long volume)
{
    Mix_Volume(-1,volume);
    Mix_VolumeMusic(volume);
}
Exemple #8
0
 void setTransform(const SoundTransform &inTransform) 
 {
    if (mMusic>=0)
       Mix_VolumeMusic( inTransform.volume*MIX_MAX_VOLUME );
 }
 void MUS_changeVolume(int volume)
 {
     Mix_VolumeMusic(volume);
     qDebug() << QString("Mix_VolumeMusic: %1\n").arg(volume);
 }
bool SDLAudio::SetVolumeMUS(int volume)
{
    Mix_VolumeMusic(volume);
    return true;
}
void C4MusicFileSDL::SetVolume(int iLevel)
{
	Mix_VolumeMusic((int) ((iLevel * MIX_MAX_VOLUME) / 100));
}
Exemple #12
0
//----------------------------------- Main -------------------------------------
int main(int argc, char *argv[])
{
    std::string cheat_string = "cheat";
    //std::locale::global( std::locale( "" ) );
    events_init();
    game.log.File_Set("Star.P.G..log");
    game.log.File_Clear();
    if (argc > 1)
    {
        for (int count = 0; count < (argc+1); count++)
        {
            //game.log.File_Write(argv[count]);
            if (cheat_string.compare(argv[count]) == 0) game_o.cheats_enabled = true;
        }
    }
    //game_o.cheats_enabled = true; /// test!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    game.log.File_Write("------------------");
    game.log.File_Write("| Star.P.G V1.01 |");
    game.log.File_Write("------------------\n");
    game.log.File_Write("Starting up!");
    game.log.File_Write("");
    game.log.File_Write("------------------\n");
    //if (game_o.cheats_enabled) game.log.File_Write("Cheating enabled!\n");
    game.config.File_Set("Star.P.G..cfg");
    game.config.Set_Defaults();
    game.log.File_Write("Loading config...");
    game.config.File_Set("Star.P.G..cfg");
    game.config.File_Read();
    game.log.File_Write("Loading language file -> data/configuration/languages/"+game.config.language+".txt");
    game_o.language.load("data/configuration/languages/"+game.config.language+".txt");
 //----------------------------------- Start the PhysicsFS ----------------------
    //game.log.File_Write("Starting PhysicsFS...");
    //PHYSFS_init(argv[0]);
    //PHYSFS_addToSearchPath("Star.P.G..spg", 1);
//----------------------------------- SDL Video --------------------------------
    game.log.File_Write("Starting SDL...");
    char SDL_VID_WIN_POS[] = "SDL_VIDEO_WINDOW_POS";
    char SDL_VID_CENTERD[] = "SDL_VIDEO_CENTERED=1";
    putenv(SDL_VID_WIN_POS);
    putenv(SDL_VID_CENTERD);
    getenv("SDL_VIDEO_WINDOW_POS");
    getenv("SDL_VIDEO_CENTERED");
    SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTTHREAD);
    game.log.File_Write("Starting OpenGL...");
    if (game.config.Display_Fullscreen) SDL_SetVideoMode(game.config.Display_X_Resolution,game.config.Display_Y_Resolution,game.config.Display_BPS,SDL_OPENGL | SDL_FULLSCREEN);
    else SDL_SetVideoMode(game.config.Display_X_Resolution,game.config.Display_Y_Resolution,game.config.Display_BPS,SDL_OPENGL/* | SDL_NOFRAME */);
    SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
    App_Icon_Surface = SDL_LoadBMP(App_Icon);
    colorkey = SDL_MapRGB(App_Icon_Surface->format, 255, 0, 255);
    SDL_SetColorKey(App_Icon_Surface, SDL_SRCCOLORKEY, colorkey);
    SDL_WM_SetIcon(App_Icon_Surface,NULL);
    SDL_WM_SetCaption(App_Name, 0);
    //SDL_ShowCursor(SDL_DISABLE);
//----------------------------------- SDL Audio --------------------------------
    game.log.File_Write("Starting sound system...");
    SDL_Init(SDL_INIT_AUDIO);
    Mix_AllocateChannels(game.config.Audio_Channels);
    Mix_OpenAudio(game.config.Audio_Rate, AUDIO_S16, 2, game.config.Audio_Buffers);
    Mix_Volume(-1,game.config.Audio_Sound_Volume);
    Mix_VolumeMusic(game.config.Audio_Music_Volume);
    game.log.File_Write("Initializing joystick / gamepad...");
    SDL_Init(SDL_INIT_JOYSTICK);
    game.log.File_Write("Initializing game system...");
    init_game(false);
    game.log.File_Write("Initializing projectiles...");
    init_player_bullets();
    game.log.File_Write("Initializing explosions...");
    init_explosions();
    game.log.File_Write("Initializing NPCs...\n");
    init_active_npcs();
    init_npc_bullets();
    init_npcs(0);
    game_o.current_level = 0;
    game.log.File_Write("Initializing OpenGL...");
    game.graphics.init_gl(game.config.Display_X_Resolution,game.config.Display_Y_Resolution);
    seed_rand();
    TTF_Init();
    game.log.File_Write("Loading resources...");
    loading_screen_display("data/textures/misc/loading_screen.png");
    load_resources();
    game.log.File_Write("Initializing menu system...");
    init_menu();
    init_in_game_message_class();
    init_projectiles(false);
    init_powerups();
    init_shields(false);
    init_game(false);
    game.log.File_Write("Starting game...");
    game.log.File_Write("---------------\n");
//----------------------------------- Main loop --------------------------------
    game.timer.start();
    game.LastTicks = game.timer.getticks();
    for(int quit = 0; !quit;)
    {
        game.config.process(false);
        if (game.config.mouse_autohide) SDL_ShowCursor(SDL_DISABLE);
        else SDL_ShowCursor(SDL_ENABLE);
        proc_textures();
        events_process();
        if (game.status_quit_active) quit = 1;
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//****************************************** MENU *****************************************
        if (game.menu_active)
        {
            SDL_ShowCursor(SDL_ENABLE);
            if (game.music_next_track)
            {
                music.menu_00.play();
                game.music_next_track = false;
            }
            diplay_menu ();
            if (game.process_ready) game.background.process();
            if (game.process_ready) process_menu();
        }
//****************************************** GAME *****************************************
        if (game.game_active)
        {
            if (game.music_next_track)
            {
                game.music_next_track = false;
                if (game.music_track ==  0) music.level_00.play();
                if (game.music_track ==  1) music.level_01.play();
                if (game.music_track ==  2) music.level_02.play();
                if (game.music_track ==  3) music.level_03.play();
                if (game.music_track ==  4) music.level_04.play();
                if (game.music_track ==  5) music.level_05.play();
                if (game.music_track ==  6) music.level_06.play();
                if (game.music_track ==  7) music.level_07.play();
                if (game.music_track ==  8) music.level_08.play();
                if (game.music_track ==  9) music.level_09.play();
                if (game.music_track == 10) music.level_10.play();
                if (game.music_track == 11) music.level_11.play();
                if (game.music_track == 12) music.level_12.play();
                if (game.music_track == 13) music.level_13.play();
                if (game.music_track == 14) music.level_14.play();
                if (game.music_track == 15) music.level_15.play();
                if (game.music_track == 16) music.level_16.play();
                if (game.music_track == 17) music.level_17.play();
                if (game.music_track == 18) music.level_18.play();
                if (game.music_track == 19) music.level_19.play();
                if (game.music_track == 20) music.level_20.play();
                if (game.music_track == 21) music.level_21.play();
                if (game.music_track == 22) music.level_22.play();
                if (game.music_track == 23) music.level_23.play();
                if (game.music_track == 24) music.level_24.play();
                if (game.music_track == 25) music.level_25.play();
            }
            game.game_resume = true;
            if (game.process_ready) process_game();
            display_game();
            if ((game.config.Display_Touchscreen) && (game.process_ready))
            {
                if(game.physics.point_in_quadrangle(-0.875f,0.2f,-0.550f,0.2f,game.io.mouse_x,game.io.mouse_y)) game.io.left = true;
                if(game.physics.point_in_quadrangle(-0.475f,0.2f,-0.550f,0.2f,game.io.mouse_x,game.io.mouse_y)) game.io.right = true;
                if(game.physics.point_in_quadrangle(-0.675f,0.2f,-0.350f,0.2f,game.io.mouse_x,game.io.mouse_y)) game.io.up = true;
                if(game.physics.point_in_quadrangle(-0.675f,0.2f,-0.750f,0.2f,game.io.mouse_x,game.io.mouse_y)) game.io.down = true;
                if(game.physics.point_in_quadrangle( 0.875f,0.2f,-0.750f,0.2f,game.io.mouse_x,game.io.mouse_y)) game.io.shoot = true;
                if(game.physics.point_in_quadrangle( 0.575f,0.2f,-0.750f,0.2f,game.io.mouse_x,game.io.mouse_y)) game.io.key_b = true;
                if(game.physics.point_in_quadrangle( 0.875f,0.2f, 0.750f,0.2f,game.io.mouse_x,game.io.mouse_y)) game.io.escape = true;
            }
            if (game_o.player.health < 0)
            {
                sound.menu_select_00.play();
                game.game_active             = false;
                game.game_resume             = false;
                game.pdie_active             = true;
                game.menu_level              = 8;
                game.config.menu_delay_count = 0;
                music.level_pd.play();
                game.background.set_data  ( 2, 1, 1, 0.0f, 0.0f, 0.0050f, 0.0050f, texture.background_019.ref_number);
                game.background.set_data  ( 1, 1, 1, 0.0f, 0.0f, 0.0020f, 0.0020f, texture.background_008.ref_number);
                game.background.set_active( 3, false);
                game.background.set_active( 4, false);
                game.background.set_movement_type(BOUNCE);
                SDL_WarpMouse(game.graphics.gl_to_res(game_over_menu.get_button_x_pos(1),game.config.mouse_resolution_x),game.config.mouse_resolution_y-game.graphics.gl_to_res(game_over_menu.get_button_y_pos(1),game.config.mouse_resolution_y));
                game.log.File_Write("User terminated due to insufficient health...better luck next time buddy!");
            }
        if ((game.io.escape) && (game.process_ready))
        {
            sound.menu_select_01.play();
            game.music_next_track        = true;
            game.game_active             = false;
            game.menu_level              = 1;
            game.menu_active             = true;
            game.io.escape               = false;
            game.io.keyboard_delay_count = 0;
            game.config.menu_delay_count = 0;
            while (game.config.menu_delay_count < (game.config.menu_delay/2))
            {
                game.config.menu_delay_count++;
            }
        }

        if (game_o.bomb_delay_count < game_o.bomb_delay)//bomb delay counter
        {
            game_o.bomb_delay_count++;
            if (game_o.bomb_delay_count > game_o.bomb_delay) game_o.bomb_delay_count = game_o.bomb_delay;
        }
        if ((game.io.key_b) && (game.process_ready))//user pressed "b" for bomb
        {
            if ((game_o.number_bombs > 0) && (game_o.bomb_delay_count >= game_o.bomb_delay))
            {
                game_o.number_bombs--;
                use_bomb_powerup();
                game_o.bomb_delay_count = 0;
                if (!game_o.rumble.active) sound.explosion_001.play();
                if (!game_o.rumble.active) game_o.rumble.start(0.025f,45); // shake the screen about.
            }
        }
        if (game.io.pause)
        {
            if (!game.game_paused)
            {
                game_o.paused.spawn();
                game.game_paused = true;
                game.game_active = false;
                game.io.pause    = false;
                game.menu_level  = 11;
                SDL_WarpMouse(game.graphics.gl_to_res(pause_menu.get_button_x_pos(1),game.config.mouse_resolution_x),game.config.mouse_resolution_y-game.graphics.gl_to_res(pause_menu.get_button_y_pos(1),game.config.mouse_resolution_y));
                game.config.menu_delay_count = 0;
                while (game.config.menu_delay_count < (game.config.menu_delay*16))
                {
                    game.config.menu_delay_count++;
                }
            }
            else
            {
                game.menu_active = false;
                game.game_paused = false;
                game.game_active = true;
            }
        };

        if (game_o.cheats_enabled == true)
        {
            if (game.io.key_0) game_o.victory_kills = game_o.level_kills;  //complete level
            if (game.io.key_1) spawn_powerup(1.0f,random_GLcoord(), 1);//spawn health power-up
            if (game.io.key_2) spawn_powerup(1.0f,random_GLcoord(), 2);//spawn shield level power-up
            if (game.io.key_3) spawn_powerup(1.0f,random_GLcoord(), 3);//spawn shield new power-up
            if (game.io.key_4) spawn_powerup(1.0f,random_GLcoord(), 4);//spawn thruster level power-up
            if (game.io.key_5) spawn_powerup(1.0f,random_GLcoord(), 5);//spawn thruster new power-up
            if (game.io.key_6) spawn_powerup(1.0f,random_GLcoord(), 6);//spawn weapon level power-up
            if (game.io.key_7) spawn_powerup(1.0f,random_GLcoord(), 7);//spawn weapon new power-up
            if (game.io.key_8) unlock_levels();                        //unlock all levels
            if (game.io.key_9) spawn_powerup(1.0f,random_GLcoord(), 8);//spawn bomb power-up
            if (game.io.key_a) game_o.anc_enabled   = !game_o.anc_enabled; //toggle active NPC count display
            if (game.io.key_f) game_o.fps_enabled   = !game_o.fps_enabled; //toggle active NPC count display
            if (game.io.key_q) spawn_powerup(1.0f,random_GLcoord(), 9);//spawn support ship 0 power-up
            if (game.io.key_w) spawn_powerup(1.0f,random_GLcoord(),10);//spawn support ship 1 power-up
            if (game.io.key_e) spawn_powerup(1.0f,random_GLcoord(),11);//spawn support ship 2 power-up
            if (game.io.key_r) spawn_powerup(1.0f,random_GLcoord(),12);//spawn support ship 3 power-up
            if (game.io.key_s)
            {
                if (!game_o.rumble.active) sound.explosion_001.play();
                if (!game_o.rumble.active) game_o.rumble.start(); // shake the screen about.
            }
        }

        if (game.io.shoot)
        {
           process_supportships(true);
           if(game_o.fw_rof_count >= game_o.projectile[game_o.player.front_weapon].rate_of_fire)
           {
              spawn_player_bullet(0);
              game_o.fw_rof_count = 0;
           }
           if(game_o.sw_rof_count >= game_o.projectile[game_o.player.side_weapon].rate_of_fire)
           {
              spawn_player_bullet(1);
              game_o.sw_rof_count = 0;
           }
        }
        else
        {
            process_supportships(false);
        }
        if (game.process_ready)
        {
            if (game.io.up)    process_player(1);
            if (game.io.down)  process_player(2);
            if (game.io.right) process_player(3);
            if (game.io.left)  process_player(4);
        }
        if ((game.io.key_1) && (game_o.projectile[ 0].active))
        {
            game_o.player.front_weapon = 0;
        }
        if ((game.io.key_2) && (game_o.projectile[ 1].active))
        {
            game_o.player.front_weapon = 1;
        }
        if ((game.io.key_3) && (game_o.projectile[ 2].active))
        {
            game_o.player.front_weapon = 2;
        }
        if ((game.io.key_4) && (game_o.projectile[ 3].active))
        {
            game_o.player.front_weapon = 3;
        }
        if ((game.io.key_5) && (game_o.projectile[ 4].active))
        {
            game_o.player.front_weapon = 4;
        }
        if ((game.io.key_6) && (game_o.projectile[ 5].active))
        {
            game_o.player.front_weapon = 5;
        }
    }
//*********************************** Game paused *****************************************
        if (game.game_paused)
        {
            if ((game.io.pause) && (game.process_ready))
            {
                game.menu_active = false;
                game.game_paused = false;
                game.game_active = true;
            }
            if (game.music_next_track)
            {
                game.music_next_track = false;
                music.level_pd.play();
            }
            game.menu_level = 11;
            if (game.process_ready) game.background.process();
            if (game.process_ready) process_menu();
            display_game();
            diplay_menu ();
         }
//*********************************** PLAYER DEATH SCREEN *****************************************
        if (game.pdie_active)
        {
            if (game.music_next_track)
            {
                game.music_next_track = false;
                music.level_pd.play();
            }
            diplay_menu ();
            if (game.process_ready) game.background.process();
            if (game.process_ready) process_menu();
            if (!game.pdie_active)  init_game(true);
        }
//******************************* PLAYER NEXT LEVEL SCREEN *************************************
        if (game.nlvl_active)
        {
            if (game.music_next_track)
            {
                game.music_next_track = false;
                music.level_nl.play();
            }
            game.menu_level = 9;
            if (game.process_ready) game.background.process();
            if (game.process_ready) process_menu();
            diplay_menu ();
        }
//******************************* OUTRO SCREEN *************************************************
     if (game.outr_active)
        {
            if (game.music_next_track)
            {
                game.music_next_track = false;
                music.outro_00.play();
            }
            game.menu_level = 10;
            if (game.process_ready) game.background.process();
            if (game.process_ready) process_menu();
            diplay_menu ();
        }
//---------------------------- code for end of main loop -----------------------
        game.FPS = (game.timer.getticks() - game.LastTicks);
        if ((game.timer.getticks() - game.LastTicks) >= 2)
        {
            game.LastTicks = game.timer.getticks();
            game.process_ready = true;
        }
        else game.process_ready = false;
        SDL_GL_SwapBuffers();
    }
//----------------------------------- Exit -------------------------------------
    game.log.File_Write("Saving configuration...");
    game.config.File_Set("Star.P.G..cfg");
    game.config.File_Clear();
    game.config.File_Write();
    game.log.File_Write("\n");
    game.log.File_Write("Shutting down...");
    game.log.File_Write("---------------\n");
//    game.log.File_Write("PhysicsFS deinit...");
//    PHYSFS_deinit();
    game.log.File_Write("SDL deinit...");
    SDL_Quit();
    return(0);
}
Exemple #13
0
int AudioEngine::get_music_volume() {
    return Mix_VolumeMusic(-1);
}
Exemple #14
0
void AudioEngine::set_music_volume(int volume) {
    Mix_VolumeMusic(volume); //Control the music volume.
}
int ONScripter::playSound(const char *filename, int format, bool loop_flag, int channel)
{
    if ( !audio_open_flag ) return SOUND_NONE;

    long length = script_h.cBR->getFileLength( filename );
    if (length == 0) return SOUND_NONE;

    unsigned char *buffer;

    if (format & SOUND_MUSIC && 
        length == music_buffer_length &&
        music_buffer ){
        buffer = music_buffer;
    }
    else{
        buffer = new(std::nothrow) unsigned char[length];
        if (buffer == NULL){
            fprintf( stderr, "failed to load [%s] because file size [%lu] is too large.\n", filename, length);
            return SOUND_NONE;
        }
        script_h.cBR->getFile( filename, buffer );
    }
    
    if (format & SOUND_MUSIC){
        music_info = Mix_LoadMUS_RW( SDL_RWFromMem( buffer, length ) );
        Mix_VolumeMusic( music_volume );
        Mix_HookMusicFinished( musicFinishCallback );
        if ( Mix_PlayMusic( music_info, (music_play_loop_flag&&music_loopback_offset==0.0)?-1:0 ) == 0 ){
            music_buffer = buffer;
            music_buffer_length = length;
            return SOUND_MUSIC;
        }
    }
    
    if (format & SOUND_CHUNK){
        Mix_Chunk *chunk = Mix_LoadWAV_RW(SDL_RWFromMem(buffer, length), 1);
        if (playWave(chunk, format, loop_flag, channel) == 0){
            delete[] buffer;
            return SOUND_CHUNK;
        }
    }

    /* check WMA */
    if ( buffer[0] == 0x30 && buffer[1] == 0x26 &&
         buffer[2] == 0xb2 && buffer[3] == 0x75 ){
        delete[] buffer;
        return SOUND_OTHER;
    }

    if (format & SOUND_MIDI){
        FILE *fp;
        if ( (fp = fopen(TMP_MUSIC_FILE, "wb", true)) == NULL){
            fprintf(stderr, "can't open temporaly MIDI file %s\n", TMP_MUSIC_FILE);
        }
        else{
            fwrite(buffer, 1, length, fp);
            fclose( fp );
            ext_music_play_once_flag = !loop_flag;
            if (playMIDI(loop_flag) == 0){
                delete[] buffer;
                return SOUND_MIDI;
            }
        }
    }

    delete[] buffer;
    
    return SOUND_OTHER;
}
Exemple #16
0
EXPORT void op_init_game(pdata data,pgameinfo gameinfo)
{
    //Text initialisieren
    data->text.texture=gameinfo->texttexture;
    int a;
    for (a=0; a<256; a++)
        data->text.breite[a]=gameinfo->textwidth[a];

    //Gameinforeferenzpointer speicher:
    data->gameinfo=gameinfo;

    char buffer[1024];

    //Ton vorbereiten
    sprintf(buffer,"%ssounds/i_dont_know_exactly_what_this_is.ogg",gameinfo->datafolder);
    data->snd_win=Mix_LoadWAV(buffer);
    Mix_VolumeChunk(data->snd_win,(int)(round(128.0*gameinfo->volume)));
    sprintf(buffer,"%ssounds/kettledrum.ogg",gameinfo->datafolder);
    data->snd_drum=Mix_LoadWAV(buffer);
    Mix_VolumeChunk(data->snd_drum,(int)(round(128.0*gameinfo->volume)));
    sprintf(buffer,"%ssounds/waves.ogg",gameinfo->datafolder);
    data->backgroundmusic = Mix_LoadMUS(buffer);
    data->old_music_volume=Mix_VolumeMusic((int)(trunc(96.0*gameinfo->volume)));
    Mix_FadeInMusic(data->backgroundmusic,-1,500);

    //Objekte laden
    sprintf(buffer,"%stextures/water.png",gameinfo->datafolder);
    data->water=ZWloadtexturefromfileA(buffer,0,gameinfo->texquali);
    sprintf(buffer,"%stextures/beat_paddle.png",gameinfo->datafolder);
    data->texture=ZWloadtexturefromfileA(buffer,0,gameinfo->texquali);
    sprintf(buffer,"%smodels/drum.3dm",gameinfo->datafolder);
    ZWload3dm(&(data->drum),buffer,data->texture);
    ZWcreatedrawlist(&(data->drum),gameinfo->lightquali);
    sprintf(buffer,"%smodels/schlaeger.3dm",gameinfo->datafolder);
    ZWload3dm(&(data->schlaeger),buffer,data->texture);
    ZWcreatedrawlist(&(data->schlaeger),0);
    sprintf(buffer,"%smodels/boat.3dm",gameinfo->datafolder);
    ZWload3dm(&(data->boat),buffer,data->texture);
    ZWcreatedrawlist(&(data->boat),0);
    sprintf(buffer,"%smodels/paddle.3dm",gameinfo->datafolder);
    ZWload3dm(&(data->paddle),buffer,data->texture);
    ZWcreatedrawlist(&(data->paddle),0);

    //Licht!
    ZWenablelight(0);
    ZWsetlightambient(0,0.0,0.0,0.0);
    ZWsetlightdiffuse(0,1.0,1.0,1.0);
    ZWsetlightposition(0,0.0,0.0,2.0);
    ZWsetmaterial(lnone);

    for (a=0; a<gameinfo->playernum; a++)
    {
        data->soll_position[a]=0;
        data->ist_position[a]=0;
        data->paddle_schlag[a]=0;
        data->chance[a]=false;
    }

    //Spiel ansich vorbereiten
    data->step=0;
    data->fade=1;
    data->countdown=3000;
    data->schlaeger_step=600;
    data->the_button=-1;
}
Exemple #17
0
void song::set_volume( int volume )
{
    Mix_VolumeMusic(volume);
}
Exemple #18
0
    void Sound::setVolume(int vol)
    {
		Mix_VolumeMusic(vol);
		Mix_Volume( -1, vol );
    }
Exemple #19
0
/* Initialize the music players with a certain desired audio format */
int open_music(SDL_AudioSpec *mixer)
{
#ifdef WAV_MUSIC
	if ( WAVStream_Init(mixer) == 0 ) {
		add_music_decoder("WAVE");
	}
#endif
#ifdef MODPLUG_MUSIC
	if ( modplug_init(mixer) == 0 ) {
		add_music_decoder("MODPLUG");
	}
#endif
#ifdef MOD_MUSIC
	if ( MOD_init(mixer) == 0 ) {
		add_music_decoder("MIKMOD");
	}
#endif
#ifdef MID_MUSIC
#ifdef USE_TIMIDITY_MIDI
	samplesize = mixer->size / mixer->samples;
	if ( Timidity_Init(mixer->freq, mixer->format,
	                    mixer->channels, mixer->samples) == 0 ) {
		timidity_ok = 1;
		add_music_decoder("TIMIDITY");
	} else {
		timidity_ok = 0;
	}
#endif
#ifdef USE_FLUIDSYNTH_MIDI
	if ( fluidsynth_init(mixer) == 0 ) {
		fluidsynth_ok = 1;
		add_music_decoder("FLUIDSYNTH");
	} else {
		fluidsynth_ok = 0;
	}
#endif
#ifdef USE_NATIVE_MIDI
#ifdef USE_FLUIDSYNTH_MIDI
	native_midi_ok = !fluidsynth_ok;
	if ( native_midi_ok )
#endif
#ifdef USE_TIMIDITY_MIDI
		native_midi_ok = !timidity_ok;
	if ( !native_midi_ok ) {
		native_midi_ok = (getenv("SDL_NATIVE_MUSIC") != NULL);
	}
	if ( native_midi_ok )
#endif
		native_midi_ok = native_midi_detect();
	if ( native_midi_ok )
		add_music_decoder("NATIVEMIDI");
#endif
#endif
#ifdef OGG_MUSIC
	if ( OGG_init(mixer) == 0 ) {
		add_music_decoder("OGG");
	}
#endif
#ifdef FLAC_MUSIC
	if ( FLAC_init(mixer) == 0 ) {
		add_music_decoder("FLAC");
	}
#endif
#if defined(MP3_MUSIC) || defined(MP3_MAD_MUSIC)
	/* Keep a copy of the mixer */
	used_mixer = *mixer;
	add_music_decoder("MP3");
#endif

	music_playing = NULL;
	music_stopped = 0;
	Mix_VolumeMusic(SDL_MIX_MAXVOLUME);

	/* Calculate the number of ms for each callback */
	ms_per_step = (int) (((float)mixer->samples * 1000.0) / mixer->freq);

	return(0);
}
Exemple #20
0
int main(int argc, char **argv)
{
	char nom_du_fichier[300] = "No_File_Loaded";
	if (argc > 1)
	{
		strcpy_s(nom_du_fichier, argv[1]);
	}
	char temp[20] = "";
	SDL_Window *window = nullptr;
	SDL_Renderer *render = nullptr;
	Input INPUT; inputInit(&INPUT);
	SDL_Color WHITE = { 255, 255 , 255 };
	int volume = 70;
	initVid(&window, &render, w_window, h_window);
	SDL_SetWindowTitle(window, "ColdJuke");

	TTF_Init();
	Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, MIX_DEFAULT_CHANNELS, 1024);

	Mix_Music *music = nullptr;
	music = Mix_LoadMUS(nom_du_fichier);
	Mix_PlayMusic(music, -1);
	Mix_VolumeMusic(static_cast<double>(128 / 100)*volume);
	clearWithColor(render, 80, 40, 100, 255);
	SDL_Texture *gui = imgToTex((baseProgramPath + "gui.png").c_str(), render);
	
	sprintf_s(temp, "%d%%", volume);
	SDL_Texture *tex_volume = txtToTex(temp, render, WHITE, 14);
	SDL_Texture *texte = txtToTex(nom_du_fichier, render, WHITE, 14);
	afficherGui(gui, texte, tex_volume, render);

	SDL_RenderPresent(render);
	int FPS(60), TICKS(1000 / FPS);
	long start(SDL_GetTicks()), actual(SDL_GetTicks());
	INPUT.filedrop = "";
	while (!INPUT.quit && !INPUT.key[SDL_SCANCODE_ESCAPE] && !(INPUT.leftclic && INPUT.leftclic_position_x > w_window-32 && INPUT.leftclic_position_y < 32))
	{
		inputReturn(&INPUT);

		actual = SDL_GetTicks();
		if (actual - start > TICKS)
		{
			if (INPUT.key[SDL_SCANCODE_SPACE] || (INPUT.leftclic && INPUT.leftclic_position_x < 64 && INPUT.leftclic_position_y > 64)) // Pause Play
			{
				if (Mix_PausedMusic())
				{
					Mix_ResumeMusic();
					texToRenderPart(gui, render, 100, 0, 64, 64, 64, 32, 0, 64, 64);
					SDL_RenderPresent(render);

				}
				else
				{
					Mix_PauseMusic();
					texToRenderPart(gui, render, 100, 0, 64, 64, 64, 32, 64, 64, 64);
					SDL_RenderPresent(render);

				}
				SDL_Delay(250);
			}
			if (INPUT.wheelup)
			{
				volume += 2;
				if (volume > 100)
					volume = 100;
				Mix_VolumeMusic(static_cast<double>(128 / 100)*volume);
				// Volume 
				texToRenderPart(gui, render, 100, w_window - 64, 64, 64, 64, 96, 0, 64, 64);
				sprintf_s(temp, "%d%%", volume);
				SDL_DestroyTexture(tex_volume);
				tex_volume = txtToTex(temp, render, WHITE, 14);
				// Volume Number
				texToRender(tex_volume, render, 100, w_window - 40, 85);
				SDL_RenderPresent(render);


			}
			if (INPUT.wheeldown)
			{
				volume -= 2;
				if (volume < 0)
					volume = 0;
				Mix_VolumeMusic(static_cast<double>(128 / 100)*volume);
				// Volume 
				texToRenderPart(gui, render, 100, w_window - 64, 64, 64, 64, 96, 0, 64, 64);
				sprintf_s(temp, "%d%%", volume);
				SDL_DestroyTexture(tex_volume);
				tex_volume = txtToTex(temp, render, WHITE, 14);
				// Volume Number
				texToRender(tex_volume, render, 100, w_window - 40, 85);
				SDL_RenderPresent(render);

			}
			if (INPUT.rightclic)
			{
				int x_mouse_screen; int y_mouse_screen;
				SDL_GetGlobalMouseState(&x_mouse_screen,&y_mouse_screen);
				SDL_SetWindowPosition(window, x_mouse_screen-INPUT.rightclic_position_x, y_mouse_screen-INPUT.rightclic_position_y);
				inputReturn(&INPUT);
			}
			if (INPUT.filedrop != "")
			{
				Mix_PauseMusic();
				music = Mix_LoadMUS(INPUT.filedrop);
				strcpy_s(nom_du_fichier, INPUT.filedrop);
				Mix_PlayMusic(music, -1);
				sprintf_s(temp, "%d%%", volume);
				SDL_DestroyTexture(texte);
				texte = txtToTex(nom_du_fichier, render, WHITE, 14);
				afficherGui(gui, texte, tex_volume, render);
				SDL_RenderPresent(render);

			}
			start = actual;
			INPUT.filedrop = "";
			INPUT.wheeldown = 0;
			INPUT.wheelup = 0;
		}
		else
		{
			SDL_Delay(TICKS - (actual - start));
		}
	}

	Mix_CloseAudio();
	TTF_Quit();
	SDL_Quit();
	return 0;
}
Exemple #21
0
void Music::set_volume(float vol) {
	Mix_VolumeMusic(vol * MIX_MAX_VOLUME);
}
Exemple #22
0
ADLPlayer::ADLPlayer() : MusicPlayer(settings.audio.playMusic) {
    musicVolume = MIX_MAX_VOLUME/2;
    Mix_VolumeMusic(musicVolume);

    pSoundAdlibPC = NULL;
}
Exemple #23
0
//
// PauseSong
//
static void PauseSong()
{
   paused_midi_volume = Mix_VolumeMusic(-1);
   Mix_VolumeMusic(0);
}
Exemple #24
0
void SoundManager::init()
{
    // Don't initialize sound engine twice
    if (mInstalled)
        return;

    logger->log1("SoundManager::init() Initializing sound...");

    mPlayBattle = config.getBoolValue("playBattleSound");
    mPlayGui = config.getBoolValue("playGuiSound");
    mPlayMusic = config.getBoolValue("playMusic");
    mFadeoutMusic = config.getBoolValue("fadeoutmusic");
    mMusicVolume = config.getIntValue("musicVolume");
    mSfxVolume = config.getIntValue("sfxVolume");
    mCacheSounds = config.getIntValue("uselonglivesounds");

    config.addListener("playBattleSound", this);
    config.addListener("playGuiSound", this);
    config.addListener("playMusic", this);
    config.addListener("sfxVolume", this);
    config.addListener("musicVolume", this);
    config.addListener("fadeoutmusic", this);
    config.addListener("uselonglivesounds", this);

    if (SDL_InitSubSystem(SDL_INIT_AUDIO) == -1)
    {
        logger->log1("SoundManager::init() Failed to "
            "initialize audio subsystem");
        return;
    }

    const size_t audioBuffer = 4096;
    int channels = config.getIntValue("audioChannels");
    switch (channels)
    {
        case 3:
            channels = 4;
            break;
        case 4:
            channels = 6;
            break;
        default:
            break;
    }

    const int res = Mix_OpenAudio(config.getIntValue("audioFrequency"),
        MIX_DEFAULT_FORMAT, channels, audioBuffer);

    if (res < 0)
    {
        logger->log("SoundManager::init Could not initialize audio: %s",
                    Mix_GetError());
        if (Mix_OpenAudio(22010, MIX_DEFAULT_FORMAT, 2, audioBuffer) < 0)
            return;
        logger->log("Fallback to stereo audio");
    }

    Mix_AllocateChannels(16);
    Mix_VolumeMusic(mMusicVolume);
    Mix_Volume(-1, mSfxVolume);

    info();

    mInstalled = true;

    if (!mCurrentMusicFile.empty() && mPlayMusic)
        playMusic(mCurrentMusicFile);
}
Exemple #25
0
void Music::SetVolume(int volume){
	Mix_VolumeMusic(volume);
}
Exemple #26
0
void menuHandleAction(int menuAction)
{
	if (menuAction >= 100 && menuAction < 200)
	{
		_menuSet(menuAction, 0);
	}
	else
	{
		switch (menuAction)
		{
			case MENU_ACTION_MENU_BACK:
				_menuSet(curMenu->parentMenu, 1);
				break;
			case MENU_ACTION_REMAP_KEYBOARD:
				menuState = MENU_STATE_REDEFINE_KEYS;
				remapDevice = 0;
				break;
			case MENU_ACTION_REMAP_JOYSTICK:
				menuState = MENU_STATE_REDEFINE_KEYS;
				remapDevice = 1;
				break;
			case (MENU_ACTION_SET_SAMPLE_RATE + 0):
				audioSampleRate = 11025;
				saveConfig(DATA_PATH "/data/config.cfg");
				break;
			case (MENU_ACTION_SET_SAMPLE_RATE + 1):
				audioSampleRate = 22050;
				saveConfig(DATA_PATH "/data/config.cfg");
				break;
			case (MENU_ACTION_SET_SAMPLE_RATE + 2):
				audioSampleRate = 44100;
				saveConfig(DATA_PATH "/data/config.cfg");
				break;
			case (MENU_ACTION_SET_MUSIC_VOL + 0):
				musicVol = 0;
				enableMusic = 0;
				Mix_VolumeMusic(musicVol);
				saveConfig(DATA_PATH "/data/config.cfg");
				break;
			case (MENU_ACTION_SET_MUSIC_VOL + 1):
				musicVol = 20;
				enableMusic = 1;
				Mix_VolumeMusic(musicVol);
				saveConfig(DATA_PATH "/data/config.cfg");
				break;
			case (MENU_ACTION_SET_MUSIC_VOL + 2):
				musicVol = 40;
				enableMusic = 1;
				Mix_VolumeMusic(musicVol);
				saveConfig(DATA_PATH "/data/config.cfg");
				break;
			case (MENU_ACTION_SET_MUSIC_VOL + 3):
				musicVol = 60;
				enableMusic = 1;
				Mix_VolumeMusic(musicVol);
				saveConfig(DATA_PATH "/data/config.cfg");
				break;
			case (MENU_ACTION_SET_MUSIC_VOL + 4):
				musicVol = 80;
				enableMusic = 1;
				saveConfig(DATA_PATH "/data/config.cfg");
				break;
			case (MENU_ACTION_SET_MUSIC_VOL + 5):
				musicVol = 100;
				enableMusic = 1;
				Mix_VolumeMusic(musicVol);
				saveConfig(DATA_PATH "/data/config.cfg");
				break;
			case (MENU_ACTION_SET_SFX_VOL + 0):
				sfxVol = 0;
				enableSfx = 0;
				changeVolume(-1, sfxVol);
				saveConfig(DATA_PATH "/data/config.cfg");
				break;
			case (MENU_ACTION_SET_SFX_VOL + 1):
				sfxVol = 20;
				enableSfx = 1;
				changeVolume(-1, sfxVol);
				saveConfig(DATA_PATH "/data/config.cfg");
				break;
			case (MENU_ACTION_SET_SFX_VOL + 2):
				sfxVol = 40;
				enableSfx = 1;
				changeVolume(-1, sfxVol);
				saveConfig(DATA_PATH "/data/config.cfg");
				break;
			case (MENU_ACTION_SET_SFX_VOL + 3):
				sfxVol = 60;
				enableSfx = 1;
				changeVolume(-1, sfxVol);
				saveConfig(DATA_PATH "/data/config.cfg");
				break;
			case (MENU_ACTION_SET_SFX_VOL + 4):
				sfxVol = 80;
				enableSfx = 1;
				saveConfig(DATA_PATH "/data/config.cfg");
				break;
			case (MENU_ACTION_SET_SFX_VOL + 5):
				sfxVol = 100;
				enableSfx = 1;
				changeVolume(-1, sfxVol);
				saveConfig(DATA_PATH "/data/config.cfg");
				break;
			case (MENU_ACTION_SET_SCALE + 0):
				changeVideoMode(screenWidth, screenHeight, 1, isFullscreen);
				saveConfig(DATA_PATH "/data/config.cfg");
				break;
			case (MENU_ACTION_SET_SCALE + 1):
				changeVideoMode(screenWidth, screenHeight, 2, isFullscreen);
				saveConfig(DATA_PATH "/data/config.cfg");
				break;
			case (MENU_ACTION_SET_SCALE + 2):
				changeVideoMode(screenWidth, screenHeight, 4, isFullscreen);
				saveConfig(DATA_PATH "/data/config.cfg");
				break;
			case (MENU_ACTION_SET_FULLSCREEN + 0):
				if (isFullscreen)
				{
					changeVideoMode(screenWidth, screenHeight, scale, 0);
					saveConfig(DATA_PATH "/data/config.cfg");
				}
				break;
			case (MENU_ACTION_SET_FULLSCREEN + 1):
				if (!isFullscreen)
				{
					changeVideoMode(screenWidth, screenHeight, scale, 1);
					saveConfig(DATA_PATH "/data/config.cfg");
				}
				break;
			case (MENU_ACTION_SET_FPS + 0):
				showFps = 0;
				saveConfig(DATA_PATH "/data/config.cfg");
				break;
			case (MENU_ACTION_SET_FPS + 1):
				showFps = 1;
				saveConfig(DATA_PATH "/data/config.cfg");
				break;
			case (MENU_ACTION_SET_VISIBILITY_LAYER0 + 0):
				showBackground = 0;
				break;
			case (MENU_ACTION_SET_VISIBILITY_LAYER0 + 1):
				showBackground = 1;
				break;
			case (MENU_ACTION_SET_VISIBILITY_LAYER1 + 0):
				showForeground = 0;
				break;
			case (MENU_ACTION_SET_VISIBILITY_LAYER1 + 1):
				showForeground = 1;
				break;
			case (MENU_ACTION_SET_EDIT_LAYER + 0):
				selectedEditLayer = 0;
				break;
			case (MENU_ACTION_SET_EDIT_LAYER + 1):
				selectedEditLayer = 1;
				break;
		}
	}
}
Exemple #27
0
	void Music::SetVolume(int vol){ if(vol > SDL_MIX_MAXVOLUME) { vol = SDL_MIX_MAXVOLUME; } volume = vol; Mix_VolumeMusic(vol); }
Exemple #28
0
int g_Open( char *file ) {
	char c; int i; float f;
	float screenfactor;
	unsigned long x, y;
	FILE *fp;
	char name[32];
	char valid_data[10];
	Mix_Chunk *psize;

	gameloop = 1;
	hx=xres>>1; hy=yres>>1; hz = hx;
	
	screenfactor = ((float)(xres))/320.0;
	//SDL_Rect src, dest;
	//src.x=0; dest.x=0;
	//src.y=0; dest.y=0;
	//src.w=1280*screenfactor; dest.w=0;
	//src.h=468*screenfactor; dest.h=0;
	
	// allocate memory for tables
	zbuffer = (float *) malloc(sizeof(f)*yres*xres);
	floorbuffer = (int *) malloc(sizeof(i)*yres*xres*2);
	floorbuffer_s = (int *) malloc(sizeof(i)*yres*xres*2);
	rowbuffer = (char *) malloc(sizeof(c)*yres);

	// build some tables
	map.loaded = 0;
	for( x=0; x<xres; x++ ) {
		for( y=0; y<yres; y++ ) {
			floorbuffer_s[y+x*yres]=16383;
			floorbuffer_s[y+x*yres+vidsize]=-1;
		}
	}

	// load general bitmaps
	font8_bmp = SDL_LoadBMP("images/8font.bmp");
	SDL_SetColorKey( font8_bmp, SDL_SRCCOLORKEY, SDL_MapRGB( font8_bmp->format, 255, 0, 255 ) );
	font16_bmp = SDL_LoadBMP("images/16font.bmp");
	SDL_SetColorKey( font16_bmp, SDL_SRCCOLORKEY, SDL_MapRGB( font16_bmp->format, 255, 0, 255 ) );
	r_LoadBmp("images/console.bmp", &console_bmp);
	
	// load textures
	sky2_bmp = SDL_LoadBMP("images/sky.bmp");
	sky_bmp = r_ScaleSurface(sky2_bmp, 1280*screenfactor,468*screenfactor);
	//sky_bmp = SDL_CreateRGBSurface(SDL_HWSURFACE,1280*screenfactor,468*screenfactor,32,0,0,0,0);
	//SDL_BlitSurface( SPG_Scale( sky2_bmp, screenfactor, screenfactor ), &src, sky_bmp, &dest );
	//SDL_BlitSurface( sky2_bmp, &src, sky_bmp, &dest );
	//SDL_BlitSurface( sky2_bmp, &src, sky_bmp, &dest );
	fp = fopen("images/textures.txt","r");
	for( texture_num=0; !feof(fp); texture_num++ ) {
		while( fgetc(fp) != '\n' ) if( feof(fp) ) break;
	}
	fclose(fp);
	walltex_bmp = (bitmap_t *) malloc(sizeof(bitmap_t)*texture_num);
	fp = fopen("images/textures.txt","r");
	for( x=0; !feof(fp); x++ ) {
		fscanf(fp,"%s",name); while( fgetc(fp) != '\n' ) if( feof(fp) ) break;
		r_LoadBmp(name, &walltex_bmp[x]);
	}
	fclose(fp);
	
	// load sprites
	fp = fopen("images/sprites.txt","r");
	for( sprite_num=0; !feof(fp); sprite_num++ ) {
		while( fgetc(fp) != '\n' ) if( feof(fp) ) break;
	}
	fclose(fp);
	sprite_bmp = (bitmap_t *) malloc(sizeof(bitmap_t)*sprite_num);
	fp = fopen("images/sprites.txt","r");
	for( x=0; !feof(fp); x++ ) {
		fscanf(fp,"%s",name); while( fgetc(fp) != '\n' ) if( feof(fp) ) break;
		r_LoadBmp(name, &sprite_bmp[x]);
	}
	fclose(fp);
	
	// load weapon bitmaps
	r_LoadBmp( "images/pistol1.bmp", &pistol_bmp[0] );
	r_LoadBmp( "images/pistol2.bmp", &pistol_bmp[1] );
	r_LoadBmp( "images/pistol3.bmp", &pistol_bmp[2] );
	r_LoadBmp( "images/pistol4.bmp", &pistol_bmp[3] );
	r_LoadBmp( "images/pistol5.bmp", &pistol_bmp[4] );
	r_LoadBmp( "images/shotgun1.bmp", &shotgun_bmp[0] );
	r_LoadBmp( "images/shotgun3.bmp", &shotgun_bmp[1] );
	shotgun_bmp[2] = shotgun_bmp[0];
	shotgun_bmp[3] = shotgun_bmp[0];
	shotgun_bmp[4] = shotgun_bmp[0];
	shotgun_bmp[5] = shotgun_bmp[0];
	r_LoadBmp( "images/shotgun4.bmp", &shotgun_bmp[6] );
	shotgun_bmp[7] = shotgun_bmp[6];
	r_LoadBmp( "images/shotgun5.bmp", &shotgun_bmp[8] );
	shotgun_bmp[9] = shotgun_bmp[6];
	shotgun_bmp[10] = shotgun_bmp[6];
	r_LoadBmp( "images/shotgun2.bmp", &shotgun_bmp[11] ); // swapped with shotgun[1] when needed

	// precompute some things
	sprsize = 2.45*((double)yres/240);
	texsize = 2.5*((double)yres/240);

	// load a map
	if( strstr(file,".bsm") == NULL )
		strcat(file,".bsm");
	fp = fopen(file, "rb");
	if( fp == NULL ) {
		printf( "ERROR: Could not load map file: %s\n\n", file );
		g_Close();
		exit(15);
	}
	
	// validate the file
	fread(valid_data, sizeof(char), strlen("BSDLMAP"), fp);
	if( strncmp(valid_data,"BSDLMAP",7) || fgetc(fp) != MAPVERSION ) {
		printf( "ERROR: Not a valid map file: %s\n\n", file );
		fclose(fp);
		g_Close();
		exit(46);
	}
	else
		map.loaded = 1; // lets the engine know that there's junk to be freed
	
	// header
	fread(map.name, sizeof(char), 32, fp);   // map name
	fread(map.author, sizeof(char), 32, fp); // map author
	fread(&map.width, sizeof(int), 1, fp);    // map width
	fread(&map.height, sizeof(int), 1, fp);   // map height
	
	// allocate data
	map.floors = (int *) malloc(sizeof(int)*map.width*map.height);
	map.floors_tex = (int *) malloc(sizeof(int)*map.width*map.height);
	map.floors_tex2 = (int *) malloc(sizeof(int)*map.width*map.height);
	map.ceilings = (int *) malloc(sizeof(int)*map.width*map.height);
	map.ceilings_tex = (int *) malloc(sizeof(int)*map.width*map.height);
	map.ceilings_tex2 = (int *) malloc(sizeof(int)*map.width*map.height);
	
	// map data
	fread(map.floors, sizeof(int), map.width*map.height, fp);        // floor height
	fread(map.floors_tex, sizeof(int), map.width*map.height, fp);    // lower wall texture
	fread(map.floors_tex2, sizeof(int), map.width*map.height, fp);   // floor texture
	fread(map.ceilings, sizeof(int), map.width*map.height, fp);      // ceiling height
	fread(map.ceilings_tex, sizeof(int), map.width*map.height, fp);  // upper wall texture
	fread(map.ceilings_tex2, sizeof(int), map.width*map.height, fp); // ceiling texture
	
	// close the file
	fclose(fp);
	
	// spawn the player
	if( !server ) {
		e_CreateEntity();
		player = lastentity;
		player->behavior = &e_ActPlayer;
		
		player->sizex = .5;
		player->sizey = .5;
		player->sizez = 52;
		
		player->x=2.5;
		player->y=2.5;
		player->z=0;
		player->ang=0;
	}
	vang=0;
	bob1 = 0; bob2 = 0; bob3 = 1;
	weap_mag[2]=2;
	
	// set camera
	camx=8;
	camy=2.5;
	camz=0;
	camang=0;

	// initiate SDL
	if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER ) == -1 ) {
		printf("ERROR: Could not initialize SDL. Aborting...\n\n");
		g_Close();
		exit(4);
	}
	//SDL_WM_GrabInput(SDL_GRAB_ON);
	
	// open audio
	if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)) {
		printf("Unable to open audio!\n");
		exit(1);
	}

	// create a screen surface
	screen = SDL_CreateRGBSurface(SDL_HWSURFACE,xres,yres,32,0,0,0,0);
	if( !windowed )
		screen2 = SDL_SetVideoMode( xres, yres, 32, SDL_HWSURFACE | SDL_FULLSCREEN );
	else
		screen2 = SDL_SetVideoMode( xres, yres, 32, SDL_HWSURFACE );
	if( screen == NULL || screen2 == NULL ) {
		printf("ERROR: Could not create video surface. Aborting...\n\n");
		g_Close();
		exit(5);
	}
	SDL_WM_SetCaption( "Bubbenstein/SDL\n\n", 0 );
	SDL_ShowCursor(SDL_DISABLE);
	
	// reset the clock
	ot=SDL_GetTicks();
	i_GetFrameRate();
	
	// load sound effects
	fp = fopen("sound/sounds.txt","r");
	for( sound_num=0; !feof(fp); sound_num++ ) {
		while( fgetc(fp) != '\n' ) if( feof(fp) ) break;
	}
	fclose(fp);
	sounds = (Mix_Chunk **) malloc(sizeof(psize)*sound_num);
	fp = fopen("sound/sounds.txt","r");
	for( x=0; !feof(fp); x++ ) {
		fscanf(fp,"%s",name); while( fgetc(fp) != '\n' ) if( feof(fp) ) break;
		sounds[x] = Mix_LoadWAV(name);
	}
	fclose(fp);
	
	// load music
	music = Mix_LoadMUS("music/dead.ogg");
	Mix_VolumeMusic(64);
	//Mix_PlayMusic(music, -1);
	musicplaying=0;
	
	// multiplayer
	if (SDLNet_Init() < 0) {
		g_Close();
		printf("ERROR: SDLNet_Init: %s\n", SDLNet_GetError());
		exit(EXIT_FAILURE);
	}

	// starting a server
	if( server ) {
		// listen on the host's port
		if( !(sd = SDLNet_UDP_Open(PORT)) ) {
			g_Close();
			printf("ERROR: SDLNet_UDP_Open: %s\n", SDLNet_GetError());
			exit(EXIT_FAILURE);
		}
		
		// Allocate memory for the packet
		if( !(packet = SDLNet_AllocPacket(512)) ) {
			printf("ERROR: SDLNet_AllocPacket: %s\n", SDLNet_GetError());
			exit(EXIT_FAILURE);
		}
	}
	
	// joining a server
	else if( address != NULL ) {
		if( !(sd = SDLNet_UDP_Open(0)) ) {
			g_Close();
			printf("ERROR: SDLNet_UDP_Open: %s\n", SDLNet_GetError());
			exit(EXIT_FAILURE);
		}
		
		if( SDLNet_ResolveHost(&ip, address, PORT) < 0 ) {
			printf("ERROR: SDLNet_ResolveHost: %s\n", SDLNet_GetError());
			exit(EXIT_FAILURE);
		}
		
		// Allocate memory for the packet
		if( !(packet = SDLNet_AllocPacket(512)) ) {
			printf("ERROR: SDLNet_AllocPacket: %s\n", SDLNet_GetError());
			exit(EXIT_FAILURE);
		}
	}
	
	// report a success!
	if( address == NULL )
		i_Message( "Map loaded: %s", file );
	else
		i_Message( "Map loaded: %s\nConnected to %s", file, address );
	return(0);
}
Exemple #29
0
/* Open the mixer with a certain desired audio format */
int Mix_OpenAudio(int frequency, Uint16 format, int nchannels, int chunksize)
{
	int i;
	SDL_AudioSpec desired;

	/* If the mixer is already opened, increment open count */
	if ( audio_opened ) {
		if ( format == mixer.format && nchannels == mixer.channels ) {
			++audio_opened;
			return(0);
		}
		while ( audio_opened ) {
			Mix_CloseAudio();
		}
	}

	/* Set the desired format and frequency */
	desired.freq = frequency;
	desired.format = format;
	desired.channels = nchannels;
	desired.samples = chunksize;
	desired.callback = mix_channels;
	desired.userdata = NULL;

	/* Accept nearly any audio format */
	if ( SDL_OpenAudio(&desired, &mixer) < 0 ) {
		return(-1);
	}
#if 0
	PrintFormat("Audio device", &mixer);
#endif

	/* Initialize the music players */
	if ( open_music(&mixer) < 0 ) {
		SDL_CloseAudio();
		return(-1);
	}

	num_channels = MIX_CHANNELS;
	mix_channel = (struct _Mix_Channel *) malloc(num_channels * sizeof(struct _Mix_Channel));

	/* Clear out the audio channels */
	for ( i=0; i<num_channels; ++i ) {
		mix_channel[i].chunk = NULL;
		mix_channel[i].playing = 0;
		mix_channel[i].looping = 0;
		mix_channel[i].volume = SDL_MIX_MAXVOLUME;
		mix_channel[i].fade_volume = SDL_MIX_MAXVOLUME;
		mix_channel[i].fade_volume_reset = SDL_MIX_MAXVOLUME;
		mix_channel[i].fading = MIX_NO_FADING;
		mix_channel[i].tag = -1;
		mix_channel[i].expire = 0;
		mix_channel[i].effects = NULL;
		mix_channel[i].paused = 0;
	}
	Mix_VolumeMusic(SDL_MIX_MAXVOLUME);

	_Mix_InitEffects();

	/* This list is (currently) decided at build time. */
	add_chunk_decoder("WAVE");
	add_chunk_decoder("AIFF");
	add_chunk_decoder("VOC");
#ifdef OGG_MUSIC
	add_chunk_decoder("OGG");
#endif
#ifdef FLAC_MUSIC
	add_chunk_decoder("FLAC");
#endif

	audio_opened = 1;
	SDL_PauseAudio(0);
	return(0);
}
Exemple #30
0
/*
================================================================================

Game::Update

    Gets called once per frame to perform game logic.
    The parameter dt is the time elapsed since last frame (in seconds).

================================================================================
*/
void Game::Update(float dt)
{
	// Update the robot
	if (mRobot)
	{
		// If the robot has reached the last scene
		// disable its controls and play game over animation
		if (mScene == 6 && !mRobot->GetJumping() && !mRobot->GetFalling())
		{
			mRobot->SetAutoPilot(true);
		}
		mRobot->Update(dt);
	}

	// Update the coins
	std::list<Coin*>::iterator coinIt = mCoins.begin();
	while (coinIt != mCoins.end())
	{
		Coin *coin = *coinIt;
		// Check if the robot collides with the coin
		if (mRobot->GetCollisonRect().y < coin->GetRect().y + coin->GetRect().h)
		{
			if ((mRobot->GetCollisonRect().x < coin->GetRect().x + coin->GetRect().w)
				&& (mRobot->GetCollisonRect().x + mRobot->GetCollisonRect().w > coin->GetRect().x))
			{
				if ((mRobot->GetCollisonRect().y < coin->GetRect().y + coin->GetRect().h)
					&& (mRobot->GetCollisonRect().y + mRobot->GetCollisonRect().h > coin->GetRect().y))
				{
					//I have found that the sound is delayed...So I start it a bit earlier than the actualy delete of the Coin
					if (coin->GetSoundDelay() == 0)
					{
						// You get 5 points!
						mPoints += 5;
						Mix_PlayChannel(-1, mCoinSound, 0);
						coin->SetSoundDelay(1);
					}
					//Once it has run through 4 times then it Deletes the coin
					else if (coin->GetSoundDelay() == 5)
					{
						coinIt = mCoins.erase(coinIt); // remove the entry from the list and advance iterator
						delete coin;
						coin = NULL;
					}
					else
					{
						coin->SetSoundDelay(1);
					}
				}
				else
				{
					coin->Update(dt);
					++coinIt;
				}
			}
			else
			{
				coin->Update(dt);
				++coinIt;
			}
		}
		else
		{
			coin->Update(dt);
			++coinIt;
		}
			
	}

	// update all crawlers
	std::list<Crawler*>::iterator crawlerIt = mCrawlers.begin();
    while (crawlerIt != mCrawlers.end())
	{
		Crawler *crawler =   *crawlerIt;
		if (crawler->GetState() == Crawler::CRAWLER_DEAD)
		{
			crawlerIt = mCrawlers.erase(crawlerIt); // remove the entry from the list and advance iterator
            delete crawler;              // delete the object
		}
		else
		{
			// If the robot is falling from a jump or just falling
			if (mRobot->GetVerticalVelocity() > 0.0 && (mRobot->GetJumping() || mRobot->GetFalling()))
			{
				// Check if the robot has started squashing the poor crawler
				if (mRobot->GetCollisonRect().x + mRobot->GetCollisonRect().w > crawler->GetCollisionRect().x && 
				mRobot->GetCollisonRect().x < crawler->GetCollisionRect().x + crawler->GetCollisionRect().w)
				{
					if (mRobot->GetCollisonRect().y + mRobot->GetCollisonRect().h > crawler->GetCollisionRect().y &&
						mRobot->GetCollisonRect().y < crawler->GetCollisionRect().y)
					{
						if (crawler->GetState() != CrawlerWeak::CRAWLER_DYING)
						{
							// You get 25 points!
							mPoints += 25;
							if (crawler->IsJumpedOn())
							{
								Mix_PlayChannel(-1, mStompSound, 0);
								mRobot->Bounce(-400, false);
								crawler->SetState(Crawler::CRAWLER_DYING);
							}
							else
							{
								Mix_PlayChannel(-1, mStompSoundNoKill, 0);
								mRobot->Bounce(-400, false);
								crawler->SetState(Crawler::CRAWLER_DYING);
							}
						}
					}
				}
			}
			// If the robot runs into a crawler, the robot must die (but it should not falling onto it from above)
			else if (mRobot->GetCollisonRect().x + mRobot->GetCollisonRect().w > crawler->GetCollisionRect().x && 
				mRobot->GetCollisonRect().x < crawler->GetCollisionRect().x + crawler->GetCollisionRect().w)
			{
				if (mRobot->GetCollisonRect().y + mRobot->GetCollisonRect().h > crawler->GetCollisionRect().y && 
				mRobot->GetCollisonRect().y < crawler->GetCollisionRect().y + crawler->GetCollisionRect().h)
				{
					if (!mRobot->IsDead() && mRobot->GetVerticalVelocity() == -850.0f && crawler->GetState() != CrawlerWeak::CRAWLER_DYING)
					{
						// You lose a life:(
						mRobot->SetLives(mRobot->GetLives() - 1);
						Mix_PlayChannel(-1, mDieSound, 0);
						// Stop the background music
						Mix_HaltMusic();
						if (mRobot->GetLives() == 0)
						{
							printf("\nGame over music is being played!");
							Mix_VolumeMusic(32);
							Mix_PlayMusic(mBadGameOverMusic, 0);
							SetEntitiesGrayscale(true);
						}
						mRobot->Bounce(-400, true);             // kill the robot
					}
				}
			}
			crawler->Update(dt);
			++crawlerIt;
		}
    }

    //
    // update the explosions
    //
    std::list<Explosion*>::iterator it = mExplosions.begin();
    while (it != mExplosions.end())
	{

        Explosion* entity = *it;        // get a pointer to this explosion

        if (entity->IsFinished())
		{
            it = mExplosions.erase(it); // remove the entry from the list and advance iterator
            delete entity;              // delete the object
        } 
		else
		{
            entity->Update(dt);     // update the entity
            ++it;                   // advance list iterator
        }
    }

	//
    // update the meteors
    //
    std::list<Meteor*>::iterator metIt = mMeteors.begin();
    while (metIt != mMeteors.end())
	{
        Meteor* entity = *metIt;        // get a pointer to this meteor

		// If the meteor has either reached the ground, destroy it with an explosion
        if (entity->GetRect().y > mScrHeight-32-64) 
		{
			if (!mRobot->IsDead())
			{
				Mix_PlayChannel(-1, mThudSound, 0);
			}
			Explosion* boom = new Explosion(entity->GetRect().x + entity->GetRect().w / 2, entity->GetRect().y + entity->GetRect().h / 2);
            mExplosions.push_back(boom);
            metIt = mMeteors.erase(metIt); // remove the entry from the list and advance iterator
            delete entity;              // delete the object
        }
		// If the meteor has hit the robot from the top, destroy it with an explosion and also kill the robot
		else if (entity->GetRect().y + entity->GetRect().h > mRobot->GetCollisonRect().y &&
				entity->GetRect().y < mRobot->GetCollisonRect().y + mRobot->GetCollisonRect().h &&
				entity->GetRect().x + entity->GetRect().w > mRobot->GetCollisonRect().x &&
				entity->GetRect().x < mRobot->GetCollisonRect().x + mRobot->GetCollisonRect().w && !mRobot->IsDead())
		{
			// You lose a life:(
			mRobot->SetLives(mRobot->GetLives() - 1);
			Mix_PlayChannel(-1, mThudSound, 0);
			Mix_PlayChannel(-1, mDieSound, 0);
			// Stop the background music
			Mix_HaltMusic();
			if (mRobot->GetLives() == 0)
			{
				Mix_VolumeMusic(32);
				Mix_PlayMusic(mBadGameOverMusic, 0);
				SetEntitiesGrayscale(true);
			}
			mRobot->Bounce(-400, true);             // kill the robot
			Explosion* boom = new Explosion(entity->GetRect().x + entity->GetRect().w / 2, entity->GetRect().y + entity->GetRect().h / 2);
			mExplosions.push_back(boom);
			metIt = mMeteors.erase(metIt); // remove the entry from the list and advance iterator
			delete entity;              // delete the object
		}
		else
		{
            entity->Update(dt);     // update the entity
            ++metIt;                   // advance list iterator
        }
    }

	//
    // update the mushrooms
    //
    std::list<Layer*>::iterator mushIt = mMushrooms.begin();
    while (mushIt != mMushrooms.end())
	{
        Layer* entity = *mushIt;
		// If the robot collects the mushroom, it gets an extra life!
		if (entity->GetRect().y + entity->GetRect().h > mRobot->GetCollisonRect().y &&
			entity->GetRect().y < mRobot->GetCollisonRect().y + mRobot->GetCollisonRect().h &&
			entity->GetRect().x + entity->GetRect().w > mRobot->GetCollisonRect().x &&
			entity->GetRect().x < mRobot->GetCollisonRect().x + mRobot->GetCollisonRect().w && !mRobot->IsDead())
		{
			mRobot->SetLives(mRobot->GetLives() + 1);
			SetFlashesNeeded(2);
			Mix_PlayChannel(-1, mOneupSound, 0);
			mushIt = mMushrooms.erase(mushIt); // remove the entry from the list and advance iterator
			delete entity;              // delete the object
		}
		else
		{
            ++mushIt;                   // advance list iterator
        }
    }

	//
    // generates a grayscale flash every 50 ms (if needed)
    //
	if (mFlashesNeeded > 0.0f)
	{
		if (mTime - mFlashTime > 0.1)
		{
			if ((int)mFlashesNeeded % 2)
			{
				SetEntitiesGrayscale(false);
			}
			else
			{
				SetEntitiesGrayscale(true);
			}
			mFlashesNeeded--;
			mFlashTime = mTime;
		}
	}

	//
    // create a new meteor every 0.2 to 1.2 seconds in scene 5
    //
	if (mTime - mMeteorTime > GG::UnitRandom() + 0.2 && mScene == 5)
	{
		int randomX = GG::RandomInt(mScrWidth-64);
		int randomRotation = GG::RandomInt(90) + 180;
		randomRotation = (randomRotation % 2) ? randomRotation : -randomRotation;
		Meteor* meteor = new Meteor(randomX, -64, (double)randomRotation);  
		mMeteors.push_back(meteor);
		// timestamp this meteor!
		mMeteorTime = mTime;
	}

	// Update the points label
	mTexMgr->DeleteTexture("PointsLabel");
	std::stringstream newLabel;
	newLabel << "Points = " << mPoints;
	SDL_Color text_color = {0, 0, 0};
	mTexMgr->LoadTexture("PointsLabel", newLabel.str().c_str(), text_color);
	delete mPointsLabel;
	mPointsLabel = new Label(10.0f, -5.0f, "PointsLabel");

	// Update the lives label
	mTexMgr->DeleteTexture("LivesLabel");
	newLabel.str(std::string());
	newLabel << "Lives = " << mRobot->GetLives();
	text_color.r = 255;
	text_color.g = 50;
	text_color.b = 50;
	mTexMgr->LoadTexture("LivesLabel", newLabel.str().c_str(), text_color);
	delete mLivesLabel;
	mLivesLabel = new Label(140.0f, -5.0f, "LivesLabel");
}