/* * Stops playing the sound. Usually for sound tracks that are played in a loop. */ void Tetris::Utils::SoundManager::stopSound(Tetris::Utils::SoundManager::SoundTrack sound) { if (sound == GAME_MUSIC) { al_stop_sample(&gameMusicId); } else if (sound == MISSION_IMPOSSIBLE) { al_stop_sample(&missionImpossibleId); } else if (sound == CRASH) { al_stop_sample(&crashId); } }
void mute(void){ if(soundtrack){ al_stop_sample(&id); al_destroy_sample(soundtrack); soundtrack=NULL; } }
void AudioManager::setAudioCue(ALLEGRO_SAMPLE* newCue) { static bool first = true; if (!first) { al_stop_sample(currentSample); } else { first = false; } al_play_sample(newCue, 0.7f, 0.0f, 1.0f, ALLEGRO_PLAYMODE_LOOP, currentSample); }
void brisa(void){ if(soundtrack){ al_stop_sample(&id); al_destroy_sample(soundtrack); soundtrack=NULL; } soundtrack = al_load_sample("brisa.wav"); // pájaros de motoneta if (!soundtrack) { printf( "Audio clip sample not loaded!\n" ); } al_play_sample(soundtrack, 1.0, 0.0,1.0,ALLEGRO_PLAYMODE_ONCE,&id); // le doy play a la canción }
// Destructor menu::~menu(){ // Stops music al_stop_sample( ¤tMusic); // Destroy samples al_destroy_sample( music_mainmenu); // Destroy images al_destroy_bitmap( buffer); al_destroy_bitmap( img_menu); al_destroy_bitmap( options); al_destroy_bitmap( helpScreen); al_destroy_bitmap( controls); al_destroy_bitmap( credits); al_destroy_bitmap( highscores_table); al_destroy_bitmap( start); al_destroy_bitmap( title); al_destroy_bitmap( highscores_button); al_destroy_bitmap( mouse); al_destroy_bitmap( mouse_rocket); al_destroy_bitmap( xbox_start); al_destroy_bitmap( ui_sound[0]); al_destroy_bitmap( ui_sound[1]); al_destroy_bitmap( ui_music[0]); al_destroy_bitmap( ui_music[1]); al_destroy_bitmap( ui_screenshake[0]); al_destroy_bitmap( ui_screenshake[1]); al_destroy_bitmap( ui_screenshake[2]); al_destroy_bitmap( ui_screenshake[3]); al_destroy_bitmap( ui_window[0]); al_destroy_bitmap( ui_window[1]); al_destroy_bitmap( ui_particle[0]); al_destroy_bitmap( ui_particle[1]); al_destroy_bitmap( ui_particle[2]); al_destroy_bitmap( ui_particle[3]); al_destroy_bitmap( ui_control[0]); al_destroy_bitmap( ui_control[1]); al_destroy_bitmap( ui_control[2]); al_destroy_bitmap( ui_options); al_destroy_bitmap( ui_options_small); al_destroy_bitmap( ui_back); al_destroy_bitmap( ui_credits); al_destroy_bitmap( ui_exit); al_destroy_bitmap( ui_help); al_destroy_bitmap( ui_screenshot_notification); al_destroy_bitmap( ui_controls); }
void stopSample(ALLEGRO_SAMPLE_ID *sampleID) { if (sampleID != NULL) { al_stop_sample(sampleID); } }
void Stop() { al_stop_sample(&mChannel); }
AudioManager::~AudioManager() { al_stop_sample(currentSample); //dtor }
void AudioManager::stopAudio() { al_stop_sample(currentSample); }
void freestop_sound(struct Sound* sound) { al_stop_sample(&(sound->id)); al_destroy_sample(sound->data); free(sound); }
void TEnterprise::Do_ai() { if (g_blGodMode) { for (size_t i=0;i< m_lstHealth.size();i++) { if (m_lstHealth[i]<m_nMaxHealth) { m_lstHealth[i] = m_nMaxHealth; } } } // Destruction rules if (m_lstHealth[HLT_HULL]<=0) { al_stop_sample(&phaser_id); Explode(); } else if (m_blDocking) { Dock(m_pBaseTarget); } else if (m_blReleasing) { Release(m_pBaseTarget); } else { if (((m_pTarget!=NULL)&&((m_pTarget->m_blDocked)|| (m_pTarget->m_blDestroyed)|| (m_pTarget->m_CloakState == CS_CLOAKED)))|| (m_lstHealth[HLT_SENSOR]<30)|| (m_lstHealth[HLT_COMPUTER]<30)) m_pTarget=NULL; if (m_pEngine->m_blKeys[SEEK_TARGET]) { if (!m_blDocked) { if (m_lstHealth[HLT_SENSOR]>30) { if (m_lstHealth[HLT_COMPUTER]>30) { m_pTarget = (TShip*)m_pEngine->Seek(m_Member,true,m_dViewDistance,m_dX,m_dY); } else { g_pCommunication->AddMessage(11,CREW_SPOCK," The computer is having trouble"); } } else { g_pCommunication->AddMessage(12,CREW_SPOCK," Our sensors are in a weak condition"); } } else { g_pCommunication->AddMessage(13,CREW_SPOCK," We are docked jim !"); } } else if (m_pEngine->m_blKeys[SEEK_FRIEND]) { if (!m_blDocked) { if (m_lstHealth[HLT_SENSOR]>30) { if (m_lstHealth[HLT_COMPUTER]>30) { if (g_blGodMode) { m_pTarget = (TShip*)m_pEngine->Seek(ID_ROMULAN_BASE, m_dViewDistance, m_dX,m_dY); } else { m_pTarget = (TShip*)m_pEngine->Seek(m_Member,false,m_dViewDistance,m_dX,m_dY); } } else { g_pCommunication->AddMessage(11,CREW_SPOCK," The computer is having trouble"); } } else { g_pCommunication->AddMessage(12,CREW_SPOCK," Our sensors are in a weak condition"); } } else { g_pCommunication->AddMessage(13,CREW_SPOCK," We are docked jim !"); } } if (m_pEngine->m_blKeys[PHASER]) { if (!m_blDocked) { if (m_lstHealth[HLT_PHASER]>30) { if (m_pTarget!=NULL) { if (m_dTargetDistance<500) { if ( m_nPhaserEnergy > 10) { if (!m_blPhaserOn) { SoundManager::LoopSound(SOUND::PHASER,1.0,&phaser_id); m_blPhaserOn = true; } } else { if (m_blPhaserOn) { SoundManager::StopSound(&phaser_id); m_blPhaserOn = false; } } } else { g_pCommunication->AddMessage(15,CREW_SPOCK," Target out of range"); if (m_blPhaserOn) { SoundManager::StopSound(&phaser_id); m_blPhaserOn = false; } } } else { if (m_blPhaserOn) { SoundManager::StopSound(&phaser_id); m_blPhaserOn = false; } else { g_pCommunication->AddMessage(15,CREW_SPOCK," There is nothing to lock on"); } } } else { g_pCommunication->AddMessage(16,CREW_SPOCK," Phasers are in bad shape"); if (m_blPhaserOn) { SoundManager::StopSound(&phaser_id); m_blPhaserOn = false; } } } else { g_pCommunication->AddMessage(14,CREW_SPOCK," Your actions seem illogical"); if (m_blPhaserOn) { SoundManager::StopSound(&phaser_id); m_blPhaserOn = false; } } } else { if (m_blPhaserOn) { SoundManager::StopSound(&phaser_id); m_blPhaserOn = false; } } if (m_pEngine->m_blKeys[PHOTON]) { m_dAimangle=m_dAngle; PrecalcFireAngles(75); FirePhoton(false); } else if (m_pEngine->m_blKeys[PHOTON_BACK]) { m_dAimangle=m_dAngle+PI; PrecalcFireAngles(30); FirePhoton(true); } else if (m_pEngine->m_blKeys[PROBE]) { LaunchProbe(); } if ((!m_blDocked)&&(!m_blDocking)&&(!m_blReleasing)) { if ((!m_blDocked)&&(!m_blDocking)&&(m_pEngine->m_blKeys[DOCK])) { m_pBaseTarget=(TShip *) m_pEngine->Seekstarbase(MEM_FEDERATION,false,m_dViewDistance,m_dX,m_dY); if ((m_pBaseTarget!=NULL)&&(!m_pBaseTarget->m_blDestroyed)) { double b_distance = Distance(m_dX,m_dY,m_pBaseTarget->GetX(),m_pBaseTarget->GetY()); if (b_distance< 250) { m_pTarget=m_pBaseTarget; m_blDocking=true; m_blReleasing=false; } } } if (m_nWarpFactor>0) { if ((m_pEngine->m_blKeys[DOWN])||(m_pEngine->m_blKeys[WARP_0])) { StopWarp(); } else if (m_pEngine->m_blKeys[LEFT]) { if (g_nScreenMode == MODE_MAINSCREEN) { m_dAngle-=m_lstHealth[HLT_THRUSTER]*0.0001; } } else if (m_pEngine->m_blKeys[RIGHT]) { if (g_nScreenMode == MODE_MAINSCREEN) { m_dAngle+=m_lstHealth[HLT_THRUSTER]*0.0001; } } else { DoWarp(); } } else { if (m_pEngine->m_blKeys[WARP_1]) { StartWarp(1); } else if (m_pEngine->m_blKeys[WARP_2]) { StartWarp(2); } else if (m_pEngine->m_blKeys[WARP_3]) { StartWarp(3); } else if (m_pEngine->m_blKeys[WARP_4]) { StartWarp(4); } else if (m_pEngine->m_blKeys[WARP_5]) { StartWarp(5); } if (m_pEngine->m_blKeys[UP]) { if (g_nScreenMode == MODE_MAINSCREEN) { SetSpeed(m_dSpeed+5); } } else if (m_pEngine->m_blKeys[DOWN]) { if (g_nScreenMode == MODE_MAINSCREEN) { SetSpeed(m_dSpeed-5); } } if (m_pEngine->m_blKeys[LEFT]) { if (g_nScreenMode == MODE_MAINSCREEN) { m_dAngle-=m_lstHealth[HLT_THRUSTER]*0.0006; } } else if (m_pEngine->m_blKeys[RIGHT]) { if (g_nScreenMode == MODE_MAINSCREEN) { m_dAngle+=m_lstHealth[HLT_THRUSTER]*0.0006; } } } } if ((m_blDocked)&&(!m_blReleasing)&&(m_pEngine->m_blKeys[RELEASE])) { m_blReleasing=true; m_blDocking=false; } DoEngineering(); if ((m_pTarget!=NULL)&&(!m_pTarget->m_blDestroyed)) { m_dTargetDistance = Distance(m_dX,m_dY,m_pTarget->GetX(),m_pTarget->GetY()); } if (m_lstHealth[HLT_SENSOR]<30) { m_pEngine->m_blSensorStatic=true; } else { m_pEngine->m_blSensorStatic=false; } } if ((m_nWarpFactor==0) && (m_dSpeed>(m_dMaxSpeed*m_lstHealth[HLT_IMPULSE])/100)) { m_dSpeed=(m_dMaxSpeed*m_lstHealth[HLT_IMPULSE])/100; } if (m_dSpeed <0) { m_dSpeed =0; } if ((m_blPhaserOn)&&(m_pTarget==NULL)) { al_stop_sample(&phaser_id); m_blPhaserOn = false; } if ((m_blDocked)&& ((m_pBaseTarget==NULL)||((m_pBaseTarget!=NULL)&& (m_pBaseTarget->m_blDestroyed)))) { Die(); } if (!m_blWasDocked && m_blDocked) { g_pCommunication->AddMessage(3,CREW_CHECOV," Enterprise is docked captain !"); m_blWasDocked=true; } }
void AudioSample::rewind() { al_stop_sample(&m_id); }
// Update loop void menu::update(){ //Menu animations if( animation_pos < 100 && !startClicked) animation_pos += 4; if( animation_pos > 0 && startClicked) animation_pos -= 4; // Start the game if( startClicked && animation_pos <= 0) set_next_state( STATE_GAME); // Open submenu or start game if( mini_screen == MINISTATE_MENU){ // Start game with controller if( joystickListener::buttonPressed[JOY_XBOX_START] || joystickListener::buttonPressed[JOY_XBOX_A]){ startClicked = true; } // Buttons if( mouseListener::mouse_pressed & 1){ // Start game if( collision( mouseListener::mouse_x, mouseListener::mouse_x, 40, 40 + al_get_bitmap_width(start), mouseListener::mouse_y, mouseListener::mouse_y, 410, 410 + al_get_bitmap_height(start))){ startClicked = true; } // Scores else if( collision( mouseListener::mouse_x, mouseListener::mouse_x, 660, 660 + al_get_bitmap_width(highscores_button), mouseListener::mouse_y, mouseListener::mouse_y, 30, 30 + al_get_bitmap_height(highscores_button))){ updateScores( scores); mini_screen = MINISTATE_SCORES; } // Credits menu else if( collision( mouseListener::mouse_x, mouseListener::mouse_x, 542, 644, mouseListener::mouse_y, mouseListener::mouse_y, 548, 600)){ mini_screen = MINISTATE_CREDITS; } // Controls menu else if( collision( mouseListener::mouse_x, mouseListener::mouse_x, 644, 696, mouseListener::mouse_y, mouseListener::mouse_y, 548 ,600)){ mini_screen = MINISTATE_CONTROLS; } // Help screen else if( collision( mouseListener::mouse_x, mouseListener::mouse_x, 696, 749, mouseListener::mouse_y, mouseListener::mouse_y, 548, 600)){ mini_screen = MINISTATE_TUTORIAL; } // Options menu else if( collision( mouseListener::mouse_x, mouseListener::mouse_x, 749, 800, mouseListener::mouse_y, mouseListener::mouse_y, 548, 600)){ mini_screen = MINISTATE_OPTIONS; } } } // Exit menus else if( mini_screen == MINISTATE_TUTORIAL || mini_screen == MINISTATE_CREDITS || mini_screen == MINISTATE_CONTROLS || mini_screen == MINISTATE_SCORES ){ if( keyListener::lastKeyPressed != -1 || mouseListener::mouse_pressed & 1 || joystickListener::lastButtonPressed != -1){ mini_screen = MINISTATE_MENU; draw(); } } // Options else if( mini_screen == MINISTATE_OPTIONS && mouseListener::mouse_pressed & 1){ // Particles toggle if( collision( 280, 360, mouseListener::mouse_x, mouseListener::mouse_x, 400, 480, mouseListener::mouse_y, mouseListener::mouse_y)){ settings[SETTING_PARTICLE_TYPE] = (settings[SETTING_PARTICLE_TYPE] + 1) % 4; } // Sound button toggle else if( collision( 120, 200, mouseListener::mouse_x, mouseListener::mouse_x, 180, 260, mouseListener::mouse_y, mouseListener::mouse_y)){ settings[SETTING_SOUND] = (settings[SETTING_SOUND] + 1) % 2; } // Music button toggle else if( collision( 280, 360, mouseListener::mouse_x, mouseListener::mouse_x, 180, 260, mouseListener::mouse_y, mouseListener::mouse_y)){ settings[SETTING_MUSIC] = (settings[SETTING_MUSIC] + 1) % 2; if( settings[SETTING_MUSIC] == 0) al_stop_sample( ¤tMusic); else al_play_sample( music_mainmenu, 1.0, 0.0, 1.0, ALLEGRO_PLAYMODE_ONCE, ¤tMusic); } // Fullscreen toggle else if( collision( 120, 200, mouseListener::mouse_x, mouseListener::mouse_x, 400, 480, mouseListener::mouse_y, mouseListener::mouse_y)){ settings[SETTING_FULLSCREEN] = (settings[SETTING_FULLSCREEN] + 1) % 2; if( settings[SETTING_FULLSCREEN]){ // Fullscreen stuff al_destroy_display( display); al_set_new_display_flags(ALLEGRO_FULLSCREEN_WINDOW); display = al_create_display( SCREEN_W, SCREEN_H); ALLEGRO_DISPLAY_MODE disp_data; al_get_display_mode(al_get_num_display_modes() - 1, &disp_data); float sx = disp_data.width / (float)SCREEN_W; float sy = disp_data.height / (float)SCREEN_H; ALLEGRO_TRANSFORM trans; al_identity_transform(&trans); al_scale_transform(&trans, sx, sy); al_use_transform(&trans); al_hide_mouse_cursor( display); } else{ al_destroy_display( display); al_set_new_display_flags(ALLEGRO_WINDOWED); display = al_create_display( SCREEN_W, SCREEN_H); al_hide_mouse_cursor( display); } } //Screen shake else if( collision( 280, 360, mouseListener::mouse_x, mouseListener::mouse_x, 290, 370, mouseListener::mouse_y, mouseListener::mouse_y)){ settings[SETTING_SCREENSHAKE] = (settings[SETTING_SCREENSHAKE] + 1) % 4; } // Control Toggle else if( collision( 120, 200, mouseListener::mouse_x, mouseListener::mouse_x, 290, 370, mouseListener::mouse_y, mouseListener::mouse_y)){ settings[SETTING_CONTROLMODE] = ((settings[SETTING_CONTROLMODE] + 1) % 3); } // Power off else if( collision( 540, 620, mouseListener::mouse_x, mouseListener::mouse_x, 180, 260, mouseListener::mouse_y, mouseListener::mouse_y)){ write_settings(); set_next_state( STATE_EXIT); } // Exit menu else if( collision( 540, 620, mouseListener::mouse_x, mouseListener::mouse_x, 407, 487, mouseListener::mouse_y, mouseListener::mouse_y)){ mini_screen = MINISTATE_MENU; write_settings(); } } // Update mouse particles if( settings[SETTING_PARTICLE_TYPE] != 3 && mouse_rocket_up){ for( int i = 0; i < 500; i++){ if( random( 1, 10) == 1){ ALLEGRO_COLOR part_color = al_map_rgb( 255, random(0,255), 0); if( settings[SETTING_CHRISTMAS]){ int red_or_green = random( 0, 1) * 255; part_color = al_map_rgb( red_or_green, 255 - red_or_green, 0); } particle newParticle( mouseListener::mouse_x, mouseListener::mouse_y + 16, part_color, random( -2, 2), random( 8, 20), 1, settings[SETTING_PARTICLE_TYPE]); mousePart.push_back( newParticle); } } } for( unsigned int i = 0; i < mousePart.size(); i++){ mousePart.at(i).logic(); if( random( 0, 10) == 0) mousePart.erase( mousePart.begin() + i); } // Close game if( keyListener::key[ALLEGRO_KEY_ESCAPE]) set_next_state( STATE_EXIT); // Check if mouse is going up mouse_rocket_up = ( mouseListener::mouse_y < mouseMove); mouseMove = mouseListener::mouse_y; }