int tir_humain(var_game_t * var) { int z; int valide = 0; SDL_Event event; message_box(var,"A vous de tirer"); while(valide == 0) { SDL_WaitEvent(&event); if(event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_LEFT) { z = transpix_1D(event.button.x,event.button.y); if(z!=-1 && var->mer_cible_hum[z] == -1) valide = 1; } else { if(event.type == SDL_QUIT) fin(var,1); } } message_box(var,"Projectile tire"); FSOUND_PlaySound(FSOUND_FREE,var->tir_sound); SDL_Delay(2000); return z; }
void PlayerPlane::blast() { if(life<=0){ blastTime+=timer; if(blastNum<8){ glPushMatrix(); glTranslatef(x, y, 0.0f); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, othertex[2].texID); glBegin(GL_QUADS); glTexCoord2d(blastNum*0.125f,0); glVertex2f(-50.0f,-50.0f); glTexCoord2d((blastNum+1)*0.125f,0);glVertex2f( 50.0f,-50.0f); glTexCoord2d((blastNum+1)*0.125f,1);glVertex2f( 50.0f, 50.0f); glTexCoord2d(blastNum*0.125f,1); glVertex2f(-50.0f, 50.0f); glEnd(); glDisable(GL_TEXTURE_2D); glPopMatrix(); if(blastTime>30){ if(blastNum==0) FSOUND_PlaySound(FSOUND_FREE,sound_2); blastNum++; blastTime=0; } } } }
void SoundSystem::play(const FileName &fileName) { if(!mute && fileName!=FileName("none") && fileName!=FileName("")) { FSOUND_PlaySound(FSOUND_FREE, getSample(fileName)); } }
void SoundEffectFMOD::Play() { if (mHandle != NULL) { FSOUND_PlaySound(FSOUND_FREE, mHandle); } }
void CSample::Play(int channel) { if(data) { FSOUND_StopSound(channel); FSOUND_SetVolume(channel,volume); FSOUND_PlaySound(channel,data); } }
void * recept_rep(var_game_t * var ) { long rep_tir; int x,y; SDL_Rect position; /*mise en attente de la reception de la reponse*/ if(recv(var->sock_client, &rep_tir, sizeof(long),0) == -1) { fprintf(var->log_erreur,"Erreur reception reponse\n"); fclose(var->log_erreur); exit(EXIT_FAILURE); } else { rep_tir = ntohl(rep_tir); trans1D_2D(var->z,&x,&y); position.x = 400 + 30*x; position.y = 25 + 30*y; /*MAJ de la matrice cible du joueur*/ var->mer_cible_hum[var->z] = (int)rep_tir; switch(rep_tir) { case 0: message_box(var,"Votre tir a rate"); SDL_BlitSurface(var->rate,NULL,var->ecran,&position); FSOUND_PlaySound(FSOUND_FREE,var->rate_sound); break; case 1: message_box(var,"Votre tir a touche"); SDL_BlitSurface(var->touche,NULL,var->ecran,&position); FSOUND_PlaySound(FSOUND_FREE,var->touche_sound); break; case 2: var->remain_bat_cpu--; affich_score(var,1); message_box(var,"Votre tir a coule un bateau"); SDL_BlitSurface(var->touche,NULL,var->ecran,&position); FSOUND_PlaySound(FSOUND_FREE,var->coule_sound); break; } } SDL_Flip(var->ecran); pthread_exit(NULL); }
void SoundManager2::playMusic( const char* filename ){ if(isActive()){ loadMusic(filename); FSOUND_PlaySound (musicChannel, musicHandle); if(isDebug()){ printf("Music Started on Channel: %i\n", musicChannel); } //TODO cycle the music channels using swapMusicHandle and swapMusicChannel //allowing a fade in/fade out kinda deal } }
void PlayMono( short which ) { if( soundOn ) { #ifdef UseSDLMixer Mix_PlayChannel(-1, sound[which], 0); #else FSOUND_PlaySound( FSOUND_FREE, sound[which] ); #endif } }
long playSound(FSOUND_SAMPLE *handle, bool loop) { long result; result = FSOUND_PlaySound(FSOUND_FREE, handle); FSOUND_SetVolume(result, DEF_VOLUME); if (loop) FSOUND_SetLoopMode(result, FSOUND_LOOP_NORMAL); else FSOUND_SetLoopMode(result, FSOUND_LOOP_OFF); return result; }
////////////////////////////////////////////////////////////////////////////////// //playsound plays a sound from the sound index. The sounds can only be played after // they have been loaded into the sound index. returns the channel its played on ////////////////////////////////////////////////////////////////////////////////// int CSound::Playsound(int soundnum) { printf("Playing Sound\n"); for(int i =1;i< int(FSOUND_GetMaxChannels);i++) { if(!FSOUND_IsPlaying(i)) { FSOUND_PlaySound(i,FSOUND_Sample_Get(soundnum)); return i; } } return 1; }
int CSound::Loopsound(int soundnum) { for(int i =1;i< int(FSOUND_GetMaxChannels);i++) { if(!FSOUND_IsPlaying(i)) { FSOUND_PlaySound(i,FSOUND_Sample_Get(soundnum)); FSOUND_SetLoopMode(i,FSOUND_LOOP_NORMAL); return i; } } return 0; }
void ComputerPlane::blast() { if(life<=0 && explosible && blastNum<8){ glPushMatrix(); glTranslatef(x, y, 0.0f); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,othertex[2].texID); glBegin(GL_QUADS); glTexCoord2f(blastNum*0.125f, 0.0f); glVertex2f(-50.0f,-50.0f); glTexCoord2f(blastNum*0.125f+0.125f,0.0f); glVertex2f( 50.0f,-50.0f); glTexCoord2f(blastNum*0.125f+0.125f,1.0f); glVertex2f( 50.0f, 50.0f); glTexCoord2f(blastNum*0.125f, 1.0f); glVertex2f(-50.0f, 50.0f); glEnd(); glDisable(GL_TEXTURE_2D); glPopMatrix(); blastTime+=timer; if(blastTime>30){ if(blastNum==0) FSOUND_PlaySound(FSOUND_FREE,sound_2); blastNum++; blastTime=0; } if(blastNum==8){ myPlane.setScore(myPlane.getScore()+rewardScore); #ifdef HARD_LEVEL if(kind==2) { for(int i=0;i<20;i++) { Ammunition t1(x,y-25,18*i,3,100.0f,0); t1.setOwner(3); ammunitions[ammunitionIndex++]=t1; if(ammunitionIndex==MAX_AMMUNITION) ammunitionIndex=0; } } #endif leftaward(); } } }
void CAudioManager::PlaySoundClip(int id, unsigned int mode){ if(m_bValidAudio == false) return; for(int i = 0; i < m_AudioClip.size(); i++){ if(m_AudioClip[i].AudioID == id){ if(mode == 0) FSOUND_Sample_SetMode(m_AudioClip[i].handle, FSOUND_LOOP_OFF); else FSOUND_Sample_SetMode(m_AudioClip[i].handle, FSOUND_LOOP_NORMAL); //m_AudioClip[i].channelPlaying = FSOUND_PlaySound(FSOUND_FREE, m_AudioClip[i].handle); m_AudioClip[i].channelPlaying = FSOUND_PlaySound(id, m_AudioClip[i].handle); } } }
int CFMOD::PlaySample(char *sname,int wchannel,int flags) { int number_samples_playing=0; CSample *sample; if(!bfmod) return 0; sample=GetSample(sname); if(!sample) return 0; for(int i=0;i<FSOUND_GetMaxChannels();i++) { if(sample->data==FSOUND_GetCurrentSample(i)) { number_samples_playing++; } } if(number_samples_playing>=sample->max_simultaneous) return 0; if(flags) FSOUND_Sample_SetMode(sample->data, flags); FSOUND_SetVolume(wchannel,sample->volume); return FSOUND_PlaySound(wchannel,sample->data); }
void CSound::Play3dSound(FSOUND_SAMPLE *sound, int volume, float x, float y) { if (p->Options->sound == 1) { float xPos = (p->Player[p->Winsock->MyIndex]->X - x) / 2400.0f; float yPos = (p->Player[p->Winsock->MyIndex]->Y - y) / 2400.0f; if (xPos >= -1.0f && xPos <= 1.0f && yPos >= -1.0f && yPos <= 1.0f) //Within hearing range? { float soundPos[3] = {xPos, yPos, 0.0f}; int returnedChannel = FSOUND_PlaySound(FSOUND_FREE, sound); FSOUND_SetVolume(returnedChannel, volume); FSOUND_3D_SetAttributes(returnedChannel, soundPos, NULL); FSOUND_3D_SetMinMaxDistance(returnedChannel, 0.15f, 1.0f); FSOUND_Update(); } } }
//----------------------------------------------------------------------------- // Func: void CShip::loadSounds() // Desc: Sounds are loaded (hence the name). // The names of the sound files to load are hard-coded // Note: Only loads sounds for the player //----------------------------------------------------------------------------- void CShip::loadSounds() { if( initialized || !isPlayer ) { return; } char *sndFile = "audio/ambmines.wav"; //"audio/b.wav"; // sndEngine = FSOUND_Sample_Load( FSOUND_FREE, sndFile, FSOUND_8BITS | FSOUND_MONO | FSOUND_LOOP_NORMAL, 0 ); if( sndEngine == NULL ) { error.msg( "CLIENT: CShip::loadSounds(): couldn't load %s", sndFile ); } channel = FSOUND_PlaySound( FSOUND_FREE, sndEngine ); FSOUND_SetVolume( channel, 0 ); error.msg( "CLIENT: Loaded sound %s", sndFile); }
int put_song_bcast(t_sdl *sdl, int x, int y) { FSOUND_SAMPLE *turkey; FSOUND_Init(44100, 32, 0); sdl->game.rec.x = (x - sdl->scrollX) * MAP_W + 30; sdl->game.rec.y = (y - sdl->scrollY) * MAP_H + HEADER_MENU + 10; sdl->game.rec.h = 17; sdl->game.rec.w = 17; xSDL_BlitSurface(sdl->game.bcast, NULL, sdl->screen, &sdl->game.rec); SDL_UpdateRects(sdl->screen, 1, &sdl->game.rec); if ((turkey = FSOUND_Sample_Load(FSOUND_FREE, "src_graphic/sound/gobble.wav", 0, 0, 0)) == NULL) { my_printf("Warning: Sound loading failled\n"); SDL_Delay(1000); return (0); } FSOUND_PlaySound(FSOUND_FREE, turkey); SDL_Delay(1000); FSOUND_Sample_Free(turkey); FSOUND_Close(); return (1); }
bool CSoundManager::PlayWave(int Vol, int Pan, int Freq, int Nr) { if (false == InitSuccessfull) return false; int Channel; // Benutzter Channel // hört man den Sound überhaupt ? // if(Vol == 0 || its_GlobalSoundVolume == 0) return false; if(its_Sounds[Nr] == NULL) return false; // Sound spielen // Channel = FSOUND_PlaySound (FSOUND_FREE, its_Sounds[Nr]->SoundData); // Kein freier Channel gefunden ? // if (Channel == -1) return false; its_Sounds[Nr]->Channel = Channel; its_Sounds[Nr]->isPlaying = true;; // Und Werte für den Channel, in dem er gespielt wird, setzen // FSOUND_SetFrequency(Channel, Freq); FSOUND_SetVolume (Channel, int(its_GlobalSoundVolume*Vol/100.0f*2.55f)); FSOUND_SetPan (Channel, Pan); return true; } // PlayWave
void SoundManager::PlayBola(void) { FSOUND_PlaySound(FSOUND_FREE, Bola); }
/* [ [DESCRIPTION] [PARAMETERS] [RETURN_VALUE] [REMARKS] [SEE_ALSO] ] */ int main() { FSOUND_SAMPLE *samp1 = 0, *samp2 = 0; int key; int eqid1,eqid2; if (FSOUND_GetVersion() < FMOD_VERSION) { printf("Error : You are using the wrong DLL version! You should be using FMOD %.02f\n", FMOD_VERSION); return 1; } /* INITIALIZE */ FSOUND_SetBufferSize(100); /* This is nescessary to get FX to work on output buffer */ if (!FSOUND_Init(44100, 32, FSOUND_INIT_ENABLESYSTEMCHANNELFX)) { printf("Error!\n"); printf("%s\n", FMOD_ErrorString(FSOUND_GetError())); return 1; } /* LOAD SAMPLES */ /* PCM,44,100 Hz, 8 Bit, Mono */ samp1 = FSOUND_Sample_Load(FSOUND_FREE, "../../media/drumloop.wav", FSOUND_2D, 0, 0); if (!samp1) { printf("Error!\n"); printf("%s\n", FMOD_ErrorString(FSOUND_GetError())); return 1; } FSOUND_Sample_SetMode(samp1, FSOUND_LOOP_OFF); /* PCM,44,100 Hz, 16 Bit, Stereo */ samp2 = FSOUND_Sample_Load(FSOUND_FREE, "../../media/jules.mp3", FSOUND_HW2D | FSOUND_ENABLEFX, 0, 0); if (!samp2) { printf("Error!\n"); printf("%s\n", FMOD_ErrorString(FSOUND_GetError())); return 1; } /* DISPLAY HELP */ printf("FSOUND Output Method : "); switch (FSOUND_GetOutput()) { case FSOUND_OUTPUT_NOSOUND: printf("FSOUND_OUTPUT_NOSOUND\n"); break; case FSOUND_OUTPUT_WINMM: printf("FSOUND_OUTPUT_WINMM\n"); break; case FSOUND_OUTPUT_DSOUND: printf("FSOUND_OUTPUT_DSOUND\n"); break; case FSOUND_OUTPUT_ASIO: printf("FSOUND_OUTPUT_ASIO\n"); break; case FSOUND_OUTPUT_OSS: printf("FSOUND_OUTPUT_OSS\n"); break; case FSOUND_OUTPUT_ALSA: printf("FSOUND_OUTPUT_ALSA\n"); break; case FSOUND_OUTPUT_ESD: printf("FSOUND_OUTPUT_ESD\n"); break; }; printf("FSOUND Mixer : "); switch (FSOUND_GetMixer()) { case FSOUND_MIXER_QUALITY_FPU: printf("FSOUND_MIXER_QUALITY_FPU\n"); break; case FSOUND_MIXER_QUALITY_MMXP5: printf("FSOUND_MIXER_QUALITY_MMXP5\n"); break; case FSOUND_MIXER_QUALITY_MMXP6: printf("FSOUND_MIXER_QUALITY_MMXP6\n"); break; }; printf("FSOUND Driver : %s\n", FSOUND_GetDriverName(FSOUND_GetDriver())); printf("=========================================================================\n"); printf("Press 1 Play SOFTWARE sound affected by following reverb dsp unit (wet)\n"); printf(" 2 Play SOFTWARE sound unaffected by following reverb dsp unit (dry)\n"); if (FSOUND_GetOutput() == FSOUND_OUTPUT_DSOUND) { printf(" 3 Play HARDWARE FX enabled sound using Direct X 8 (echo+flange)\n"); printf(" 4 Set EQ on global software output to be affect by DX8 FX\n"); printf(" Press 1 or 2 to hear the effect (3 is unaffected)\n"); printf(" 5 Turn off EQ on global software output\n"); } printf(" ESC Quit\n"); printf("=========================================================================\n"); /* SET UP DSPS! */ SetupReverb(); /* Note if we are using a dsp unit for playing sounds, callback and parameter are ignored! */ DrySFXUnit = FSOUND_DSP_Create(NULL, FSOUND_DSP_DEFAULTPRIORITY_USER+100, 0); FSOUND_DSP_SetActive(DrySFXUnit, TRUE); /* You must pause the software output before getting the FX handle on it. */ if (FSOUND_GetOutput() == FSOUND_OUTPUT_DSOUND) { FSOUND_SetPaused(FSOUND_SYSTEMCHANNEL, TRUE); eqid1 = FSOUND_FX_Enable(FSOUND_SYSTEMCHANNEL, FSOUND_FX_PARAMEQ); eqid2 = FSOUND_FX_Enable(FSOUND_SYSTEMCHANNEL, FSOUND_FX_PARAMEQ); FSOUND_SetPaused(FSOUND_SYSTEMCHANNEL, FALSE); } /* START PLAYING! */ do { key = 0; printf("channels playing = %d cpu usage = %.02f%%\r", FSOUND_GetChannelsPlaying(), FSOUND_GetCPUUsage()); if (kbhit()) { key = getch(); if (key == '1') { int channel = FSOUND_PlaySound(FSOUND_FREE, samp1); } if (key == '2') { FSOUND_PlaySoundEx(FSOUND_FREE, samp1, DrySFXUnit, FALSE); } if (FSOUND_GetOutput() == FSOUND_OUTPUT_DSOUND) { if (key == '3') { static int fxchannel = FSOUND_FREE; static int echoid = -1, echoid2 = -1,flangeid = -1, firsttime; if (fxchannel == FSOUND_FREE) { firsttime = TRUE; } else { firsttime = FALSE; } fxchannel = FSOUND_PlaySoundEx(fxchannel, samp2, DrySFXUnit, TRUE); /* NOTE! Even though it is for hardware FX, set it to a DrySFXUnit just in case a non hardware output mode has been selected (such as WINMM/Linux etc) and it actually drops back to 100% software */ FSOUND_SetVolume(fxchannel, 120); /* turn it down a bit! */ if (firsttime) { echoid = FSOUND_FX_Enable(fxchannel, FSOUND_FX_ECHO); echoid2 = FSOUND_FX_Enable(fxchannel, FSOUND_FX_ECHO); flangeid = FSOUND_FX_Enable(fxchannel, FSOUND_FX_FLANGER); } FSOUND_SetPaused(fxchannel, FALSE); FSOUND_FX_SetEcho(echoid, 80.0f, 70.0f, 100.0f, 100.0f, TRUE); FSOUND_FX_SetEcho(echoid2, 100, 70.0f, 10, 10, FALSE); } if (key == '4') { FSOUND_FX_SetParamEQ(eqid1, 8000, 36, -15); FSOUND_FX_SetParamEQ(eqid2, 16000, 36, -15); } if (key == '5') { FSOUND_FX_SetParamEQ(eqid1, 8000, 15, 0); FSOUND_FX_SetParamEQ(eqid2, 8000, 15, 0); } } } Sleep(10); } while (key != 27); printf("\n"); /* CLEANUP AND SHUTDOWN */ FSOUND_DSP_Free(DrySFXUnit); CloseReverb(); FSOUND_Sample_Free(samp1); FSOUND_Sample_Free(samp2); FSOUND_Close(); return 0; }
void Award::eat() { if(life>0 && distance(x,y, myPlane.getX(),myPlane.getY())<30) { switch(kind) { case 0: { #if 0 if(myPlane.getAmmunitionKind()==1){ for(int i=0;i<80;i++){ Ammunition t1(myPlane.getX(),myPlane.getY(),9*i,3,300.0f,4); t1.setOwner(1); ammunitions[ammunitionIndex++]=t1; if(ammunitionIndex==MAX_AMMUNITION) ammunitionIndex=0; } } myPlane.setAmmunitionKind(1); #endif if (myPlane.getFireLevel() < 3) { myPlane.levelUp(); } else { myPlane.setScore(myPlane.getScore() + 1000); } life=0; break; } case 1: { if(myPlane.getLife()<50) myPlane.setLife(myPlane.getLife()+50); else if(myPlane.getLife()<100) myPlane.setLife(100); life=0; break; } case 2: { for(int i=0;i<80;i++){ Ammunition t1(myPlane.getX(),myPlane.getY(),9*i,3,300.0f,4); t1.setOwner(1); ammunitions[ammunitionIndex++]=t1; if(ammunitionIndex==MAX_AMMUNITION) ammunitionIndex=0; } life=0; break; } default: break; } FSOUND_PlaySound(FSOUND_FREE,sound_3); } }
void placement_hum(var_game_t * var) { int bateau,i,z,za,clic,x,y; SDL_Event event; SDL_Surface * temp; SDL_Rect position; za = -1; message_box(var,"placement des bateaux"); for(bateau=0;bateau<5;bateau++) { var->flotte_hum[bateau].sens = 0; do { clic = 0; while(!clic) { SDL_WaitEvent(&event); switch(event.type) { case SDL_QUIT: fin(var,1); break; case SDL_MOUSEBUTTONDOWN: switch(event.button.button) { case SDL_BUTTON_RIGHT: var->flotte_hum[bateau].sens = (var->flotte_hum[bateau].sens + 1)%2; x = event.button.x; y = event.button.y; z = conv_placement(x,y); if(z != -1) { trans1D_2D (z,&x,&y); if(placement_valide (x,y,var->flotte_hum[bateau].sens,var->flotte_hum[bateau].taille,var)) temp = var->frag_bat; else temp = var->touche; dessin_bateau_precedent(var,bateau); dessin_bateau_courant(var,bateau,x,y,temp); SDL_Flip(var->ecran); } break; case SDL_BUTTON_LEFT: z = conv_placement(event.button.x, event.button.y); if(z!=-1) { clic = 1; trans1D_2D (z,&x,&y); } break; } break; case SDL_MOUSEMOTION: x = event.motion.x; y = event.motion.y; z = conv_placement(x,y); if(z!=-1 && za != z) { za = z; trans1D_2D (z,&x,&y); if(placement_valide (x,y,var->flotte_hum[bateau].sens,var->flotte_hum[bateau].taille,var)) /*placement valide*/ temp = var->frag_bat; else temp = var->touche; dessin_bateau_precedent(var,bateau); dessin_bateau_courant(var,bateau,x,y,temp); SDL_Flip(var->ecran); } break; } } }while(!placement_valide (x,y,var->flotte_hum[bateau].sens,var->flotte_hum[bateau].taille,var)); dessin_bateau_courant(var,bateau,x,y,var->frag_bat); FSOUND_PlaySound(FSOUND_FREE,var->place_sound); SDL_Flip(var->ecran); var->flotte_hum[bateau].x = x; var->flotte_hum[bateau].y = y; ; /*remplissage de la matrice*/ z = trans2D_1D(x,y); if(var->flotte_hum[bateau].sens == 0) { for(i=0;i<var->flotte_hum[bateau].taille;i++) var->mer_home_hum[z+i] = bateau; } else { for(i=0;i<var->flotte_hum[bateau].taille;i++) var->mer_home_hum[z+10*i] = bateau; } } }
void Title::HandleEvents(GameEngine* game) { /*la majorité du code de l'écran titre se trouve ici (mise à jour des images inclue) étant donné le fonctionnement de l'écran titre la méthode de gestion des évènements de l'exploration peut également s'appliquer, mais il faut penser à inclure des variables static de fonction et "simuler" la répétition des touches après un certain temps appuyé sur une des deux touches (haut/bas) Ce type de code devra être simulé lors des combats si la jauge ATB reste active pendant la gestion des commandes*/ SDL_EnableKeyRepeat(400, 100); int tempsPrecedent = 0, tempsActuel = 0; FSOUND_Stream_Play(FSOUND_FREE, musique1); SDL_BlitSurface(image1,NULL,SDL_GetVideoSurface(),NULL); SDL_BlitSurface(image2,NULL,SDL_GetVideoSurface(),&image02); SDL_UpdateRect(game->screen, 0, 0, 0, 0); //SDL_EventState(SDL_KEYDOWN, SDL_IGNORE); //Désactive et annule les anciens évènements SDL_EventState(SDL_KEYDOWN, SDL_ENABLE); // Réactive les évènements while ( quit==false && positionCurseur != 0 ) { //Tant qu'il y a un événement while( SDL_WaitEvent( &game->event ) ) //////ON ATTEND QU'UN EVENEMENT SE DECLBNCHE POUR EXECUTER LES ACTIONS EN DESSOUS { switch (game->event.type) { //A retirer lorsque phase de test terminée case SDL_QUIT: //Si l'utilisateur a cliqué sur le X de la fenêtre //On quitte the programme quit = true; break; case SDL_KEYDOWN: switch (game->event.key.keysym.sym) { case SDLK_DOWN: FSOUND_PlaySound(FSOUND_FREE, sonCurseurDeplacement); positionCurseur++; if ( positionCurseur > 2 ) { positionCurseur = 1; } SDL_Delay(10); break; case SDLK_UP: FSOUND_PlaySound(FSOUND_FREE, sonCurseurDeplacement); positionCurseur--; if ( positionCurseur < 1 ) { positionCurseur = 2; } break; case SDLK_RETURN: FSOUND_PlaySound(FSOUND_FREE, sonCurseurValider); FSOUND_Stream_Stop(musique1); positionCurseur = 0; break; default:; } } if (positionCurseur == 0 && quit==false ) { for (int i = 0 ; i <= 255 ; i+=24) // transition noir { alpha = i; SDL_SetAlpha(fondu, SDL_SRCALPHA, alpha); SDL_BlitSurface(image1,NULL,SDL_GetVideoSurface(),NULL); SDL_BlitSurface(image2,NULL,SDL_GetVideoSurface(),&image02); SDL_BlitSurface(fondu, NULL, SDL_GetVideoSurface(), NULL); SDL_UpdateRect(game->screen, 0, 0, 0, 0); tempsPrecedent = tempsActuel; while( tempsActuel - tempsPrecedent < 1000 / FRAMES_PER_SECOND ) { tempsActuel = SDL_GetTicks(); } } alpha = 255; SDL_SetAlpha(fondu, SDL_SRCALPHA, alpha); SDL_BlitSurface(fondu, NULL, SDL_GetVideoSurface(), NULL); SDL_UpdateRect(game->screen, 0, 0, 0, 0); break; } if ( positionCurseur == 1 && quit==false ) { image02.x = 300; image02.y = 515; } if ( positionCurseur == 2 && quit==false) { image02.x = 300; image02.y = 539; } if ( positionCurseur != 0 && quit==false) { SDL_BlitSurface(image1,NULL,SDL_GetVideoSurface(),NULL); SDL_BlitSurface(image2,NULL,SDL_GetVideoSurface(),&image02); SDL_UpdateRect(game->screen, 0, 0, 0, 0); } break; } } game->Quit(); }
int reponse_tir(int coord ,int provenance,var_game_t * var) { int reponse = 1; int x,y,temp; SDL_Rect position; trans1D_2D(coord,&x,&y); if(provenance == 0) { /*calcul de la position du jeton indicateur*/ position.x = 400 + 30*x; position.y = 350 + 30*y; temp = var->mer_home_hum[coord]; /*cas tir procenant du cpu ou joueur en reseau*/ switch (temp) { case -1 : reponse = 0; /*tir rate*/ var->mer_home_hum[coord]=5; FSOUND_PlaySound(FSOUND_FREE,var->rate_sound); SDL_BlitSurface(var->rate,NULL,var->ecran,&position); message_box(var,"Son tir a echoue"); break; case 0: case 1: case 2: case 3: case 4: var->mer_home_hum[coord]=6; /*tir touche*/ SDL_BlitSurface(var->touche,NULL,var->ecran,&position); var->flotte_hum[temp].vie = var->flotte_hum[temp].vie -1; if(var->flotte_hum[temp].vie == 0) /*test si coule*/ { reponse = 2; FSOUND_PlaySound(FSOUND_FREE,var->coule_sound); message_box(var,"Son tir a coule un de vos bateau"); } else { FSOUND_PlaySound(FSOUND_FREE,var->touche_sound); message_box(var,"Son tir a touche un de vos bateau"); } break; } } else { /*calcul de la position du jeton indicateur*/ position.x = 400 + 30*x; position.y = 25 + 30*y; temp = var->mer_home_cpu[coord]; /*cas tir provenant joueur humain*/ switch (var->mer_home_cpu[coord]) { case -1 : reponse = 0; var->mer_home_cpu[coord]=5; SDL_BlitSurface(var->rate,NULL,var->ecran,&position); FSOUND_PlaySound(FSOUND_FREE,var->rate_sound); message_box(var,"Votre tir a echoue"); break; case 0: case 1: case 2: case 3: case 4: var->mer_home_cpu[coord]=6; var->flotte_cpu[temp].vie = var->flotte_cpu[temp].vie -1; SDL_BlitSurface(var->touche,NULL,var->ecran,&position); if(var->flotte_cpu[temp].vie == 0) { reponse = 2; FSOUND_PlaySound(FSOUND_FREE,var->coule_sound); message_box(var,"Votre tir a coule un bateau"); } else { FSOUND_PlaySound(FSOUND_FREE,var->touche_sound); message_box(var,"Votre tir a touche un bateau"); } break; } } SDL_Flip(var->ecran); return reponse; }
void CALLBACK midiCallback(HMIDIIN handle, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2) { unsigned long int on, off; BITMAP* midipress = create_bitmap(800, 95); BITMAP *piano = load_bitmap( "resources/piano.bmp", NULL); draw_sprite(midipress, piano, 35, 0); rectfill(midipress, 0, 0, 35, 95, makecol(0, 0, 0)); rectfill(midipress, 765, 0, 800, 95, makecol(0, 0, 0)); //När midi devicen väljs skickas alltid en kontrollsignal som har dwParam1 som 0 if(dwParam1==0) { printf("\nMidi input starting"); } //När dwParam1 hamnar i detta intervall brukar noten ha släppts else if(dwParam1<4230000 && dwParam1>4200000) { off = 1+((dwParam1-144)%(256*256))/256; } //Annars kan vi anta att den slogs på else { BITMAP *keyleft = load_bitmap("resources/keyleftf.bmp", NULL); BITMAP *keyright = load_bitmap("resources/keyrightf.bmp", NULL); BITMAP *keymiddle = load_bitmap("resources/keymiddlef.bmp", NULL); BITMAP *keyblack = load_bitmap("resources/keyblackf.bmp", NULL); FSOUND_STREAM* music; char fil[11]="nox/00.wav"; fil[10]='\0'; on = ((dwParam1-144)%(256*256))/256; //printf("\nOn: %ld", on); textprintf_ex(midipress, font, 10, 0, makecol(255, 255, 255), -1, "%d", on); fil[4]=(on/10)+'0'; fil[5]=(on%10)+'0'; //Noternas placering förklaras mer ingående i drawnotes.c //A if(on%12==9%12)draw_sprite(midipress, keymiddle,35+(((7*floor((on-21)/12))+0)*730/52),12); //B else if(on%12==11%12)draw_sprite(midipress, keyright,35+(((7*floor((on-21)/12))+1)*730/52),12); //C else if(on%12==0)draw_sprite(midipress, keyleft,35+(((7*floor((on-21)/12))+2)*730/52),12); //D else if(on%12==2%12)draw_sprite(midipress, keymiddle,35+(((7*floor((on-21)/12))+3)*730/52),12); //E else if(on%12==4%12)draw_sprite(midipress, keyright,35+(((7*floor((on-21)/12))+4)*730/52),12); //F else if(on%12==5%12)draw_sprite(midipress, keyleft,35+(((7*floor((on-21)/12))+5)*730/52),12); //G else if(on%12==7%12)draw_sprite(midipress, keymiddle,35+(((7*floor((on-21)/12))+6)*730/52),12); //A# else if(on%12==10%12)draw_sprite(midipress, keyblack,10+35+98*floor((on-21)/12),12); //C# else if(on%12==1%12)draw_sprite(midipress, keyblack,38+35+98*floor((on-21)/12),12); //D# else if(on%12==3%12)draw_sprite(midipress, keyblack,52+35+98*floor((on-21)/12),12); //F# else if(on%12==6%12)draw_sprite(midipress, keyblack,80+35+98*floor((on-21)/12),12); //G# else if(on%12==8%12)draw_sprite(midipress, keyblack,94+35+98*floor((on-21)/12),12); //Spelar en ljudfil av noten som slogs music=FSOUND_Sample_Load(FSOUND_FREE,fil,0,0,0); FSOUND_PlaySound (FSOUND_FREE, music); //Det går inte att fria minnet till music //eftersom ljudfilen inte spelats klart när funktionen slutar, //det blir extra svårt av att funktionen är isolerad vilket leder till att //programmet läcker ungefär 500kb minne per slagen not (storleken av ljudfilen) destroy_bitmap(keyleft); destroy_bitmap(keymiddle); destroy_bitmap(keyright); destroy_bitmap(keyblack); } blit(midipress, screen, 0, 0, 0, 505, 800, 95); destroy_bitmap(midipress); destroy_bitmap(piano); }
void SoundManager::PlayPaso(void) { FSOUND_PlaySound(FSOUND_FREE, Paso); }
glui32 glk_schannel_play_ext(schanid_t chan, glui32 snd, glui32 repeats, glui32 notify) { FILE *file; long pos, len; glui32 type; char *buf; int offset = 0; int i; if (!chan) { gli_strict_warning("schannel_play_ext: invalid id."); return 0; } /* stop previous noise */ glk_schannel_stop(chan); if (repeats == 0) return 1; /* load sound resource into memory */ if (!giblorb_is_resource_map()) { char name[1024]; sprintf(name, "%s/SND%ld", gli_workdir, snd); file = fopen(name, "rb"); if (!file) return 0; fseek(file, 0, SEEK_END); len = ftell(file); buf = malloc(len); if (!buf) { fclose(file); return 0; } fseek(file, 0, 0); fread(buf, 1, len, file); fclose(file); /* identify by file magic the two types that fmod can do... */ type = 0; /* unidentified */ /* AIFF */ if (len > 4 && !memcmp(buf, "FORM", 4)) type = giblorb_ID_FORM; /* WAVE */ if (len > 4 && !memcmp(buf, "WAVE", 4)) type = giblorb_ID_WAVE; /* MIDI */ if (len > 4 && !memcmp(buf, "MThd", 4)) type = giblorb_ID_MIDI; /* Ogg Vorbis */ if (len > 4 && !memcmp(buf, "OggS", 4)) type = giblorb_ID_OGG; /* s3m */ if (len > 0x30 && !memcmp(buf + 0x2c, "SCRM", 4)) type = giblorb_ID_MOD; /* XM */ if (len > 20 && !memcmp(buf, "Extended Module: ", 17)) type = giblorb_ID_MOD; /* MOD */ if (len > 1084) { char resname[4]; memcpy(resname, buf + 1080, 4); if (!strcmp(resname+1, "CHN") || /* 4CHN, 6CHN, 8CHN */ !strcmp(resname+2, "CN") || /* 16CN, 32CN */ !strcmp(resname, "M.K.") || !strcmp(resname, "M!K!") || !strcmp(resname, "FLT4") || !strcmp(resname, "CD81") || !strcmp(resname, "OKTA") || !strcmp(resname, " ")) type = giblorb_ID_MOD; } if (!memcmp(buf, "\377\372", 2)) /* mp3 */ type = giblorb_ID_MP3; /* look for RIFF (future boy has broken resources...?) */ if (len > 128 && type == 0) for (i = 0; i < 124; i++) if (!memcmp(buf+i, "RIFF", 4)) { offset = i; type = giblorb_ID_WAVE; break; } if (type == 0) type = giblorb_ID_MP3; } else { giblorb_get_resource(giblorb_ID_Snd, snd, &file, &pos, &len, &type); if (!file) return 0; buf = malloc(len); if (!buf) return 0; fseek(file, pos, 0); fread(buf, 1, len, file); } switch (type) { case giblorb_ID_FORM: case giblorb_ID_WAVE: case giblorb_ID_MP3: chan->sample = FSOUND_Sample_Load(FSOUND_UNMANAGED, buf + offset, FSOUND_NORMAL|FSOUND_LOADMEMORY, 0, len); if (!chan->sample) { free(buf); return 0; } if (repeats != 1) FSOUND_Sample_SetMode(chan->sample, FSOUND_LOOP_NORMAL); else FSOUND_Sample_SetMode(chan->sample, FSOUND_LOOP_OFF); chan->channel = FSOUND_PlaySound(FSOUND_FREE, chan->sample); FSOUND_SetVolume(chan->channel, chan->volume / 256); FSOUND_SetPaused(chan->channel, 0); break; case giblorb_ID_MOD: case giblorb_ID_MIDI: chan->module = FMUSIC_LoadSongEx(buf, 0, len, FSOUND_LOADMEMORY, 0, 0); if (!chan->module) { free(buf); return 0; } if (repeats != 1) FMUSIC_SetLooping(chan->module, 1); else FMUSIC_SetLooping(chan->module, 0); FMUSIC_SetMasterVolume(chan->module, chan->volume / 256); FMUSIC_PlaySong(chan->module); break; default: gli_strict_warning("schannel_play_ext: unknown resource type."); } free(buf); return 1; }
void SoundManager::PlayBoing(void) { FSOUND_PlaySound(FSOUND_FREE, Boing); }
void Jouer(SDL_Surface* ecran) { srand(time(NULL)); positionBallonOrig.x=positionBallonOrig.y=0; FSOUND_SAMPLE *pew = NULL; pew = FSOUND_Sample_Load(FSOUND_FREE, "paint.wav", 0, 0, 0); int continuer=1,etat=0; //on charge le jeu ou bien on commence un enouvelle partie //et decide la finitude de la partie int t1=0; // pour saisir l origine et la destination Ballon[EMPTY]=IMG_Load("empty.png"); Ballon[BLUE]=IMG_Load("blue.png"); Ballon[YELLOW]=IMG_Load("yellow.png"); Ballon[RED]=IMG_Load("red.png"); Ballon[GREEN]=IMG_Load("green.png"); Ballon[BLACK]=IMG_Load("black.png"); Ballon[WHITE]=IMG_Load("white.png"); Ballon[LBLUE]=IMG_Load("lblue.png"); Ballon[ATOMIC]=IMG_Load("atomic.png"); //Ballon[BOOM]=IMG_Load("boom.png"); SDL_Surface* bg=NULL; bg=IMG_Load("bg.jpg"); SDL_BlitSurface(bg,NULL,ecran,&positionBallonOrig); SDL_Surface* BallonActuel=NULL; SDL_Rect positionBallon; coefScore=1; SDL_Event event; int i,j; for(i=0;i<Nb_Bloc_Largeur;i++) for(j=0;j<Nb_Bloc_Hauteur;j++) { positionBallonOrig.x=i*Taille_Bloc+cte1; positionBallonOrig.y=j*Taille_Bloc + cte2; SDL_BlitSurface(Ballon[grille[i][j]],NULL,ecran,&positionBallonOrig); if(grille[i][j]!=0) etat=1; } if(etat==0) { Score=0; score(ecran,Score); next(ecran) ; continuer=caissier(ecran); } score(ecran,Score);// s il y a chargement alors bliter le scor et et les next ballons next(ecran); while(continuer) { SDL_WaitEvent(&event); switch(event.type) { case SDL_QUIT: continuer=0; break ; case SDL_MOUSEBUTTONUP: if(event.button.x>10 && event.button.x<109 && event.button.y>393 && event.button.y<424 ) {nouveaujeu(); continuer=0; break;} if(event.button.x>10 && event.button.x<109 && event.button.y>439 && event.button.y<472) { continuer=0; break;} if(event.button.x>cte1 && event.button.x<(450+cte1) && event.button.y>cte2 && event.button.y<(cte2+450)) { if(t1==0) { positionBallonOrig.x=event.button.x;//recuperer les coords de l origine positionBallonOrig.y=event.button.y; if(grille[(positionBallonOrig.x - cte1)/Taille_Bloc][(positionBallonOrig.y - cte2)/Taille_Bloc]!=EMPTY) { positionBallonOrig=position(positionBallonOrig); FSOUND_PlaySound(FSOUND_FREE, pew);//jouer le son SDL_BlitSurface(Ballon[ATOMIC],NULL,ecran,&positionBallonOrig); SDL_Flip(ecran); t1=1; break; } break; } if(t1==1) { positionBallonDest.x=event.button.x;//recuperer les coords de la destination positionBallonDest.y=event.button.y; if(grille[(positionBallonDest.x - cte1)/Taille_Bloc][(positionBallonDest.y - cte2)/Taille_Bloc]==EMPTY) { positionBallonDest=position(positionBallonDest); FSOUND_PlaySound(FSOUND_FREE, pew);//jouer le son t1=2; break; } else { SDL_BlitSurface(Ballon[grille[(positionBallonOrig.x-cte1)/Taille_Bloc][(positionBallonOrig.y-cte2)/Taille_Bloc]],NULL,ecran,&positionBallonOrig); FSOUND_PlaySound(FSOUND_FREE, pew);//jouer le son positionBallonOrig=position(positionBallonDest); SDL_BlitSurface(Ballon[ATOMIC],NULL,ecran,&positionBallonOrig); SDL_Flip(ecran); t1=1; break; } } } } if(t1==2) { if(Chemin(positionBallonOrig,positionBallonDest)==1) { BallonActuel=Ballon[PermuterBall(positionBallonOrig,positionBallonDest)]; // SDL_BlitSurface(BallonActuel,NULL,ecran,&positionBallonDest); //SDL_BlitSurface(Ballon[EMPTY],NULL,ecran,&positionBallonOrig); for(i=0; tri9[i].i != -1 ; i++) { positionBallon.x=tri9[i].i * Taille_Bloc + cte1; positionBallon.y=tri9[i].j * Taille_Bloc + cte2; SDL_BlitSurface(BallonActuel,NULL,ecran,&positionBallon); SDL_Flip(ecran); SDL_Delay(40); SDL_BlitSurface(Ballon[EMPTY],NULL,ecran,&positionBallon); } SDL_BlitSurface(BallonActuel,NULL,ecran,&positionBallonDest); SDL_Flip(ecran); //bombe(positionBallonDest,ecran); if(supligne(positionBallonDest,ecran)==0) { coefScore=1; etat=caissier(ecran); if(etat>0) { //SDL_Delay(100); for(i=0; i<3 && i<etat ;i++) { positionBallon.x=PNext[i].i * Taille_Bloc + cte1; positionBallon.y=PNext[i].j * Taille_Bloc + cte2; supligne(positionBallon,ecran); } next(ecran); } else {continuer=0; msgbox_terminer(); nouveaujeu();} } else coefScore++; t1=0; } else t1=1; } } // meilleurS(); SDL_free(Ballon[0]); SDL_free(Ballon[1]); SDL_free(Ballon[2]); SDL_free(Ballon[3]); SDL_free(Ballon[4]); SDL_free(Ballon[5]); SDL_free(Ballon[6]); SDL_free(Ballon[7]); SDL_free(Ballon[8]); return ; }
void SoundManager::PlayPlayerDead(void) { FSOUND_PlaySound(FSOUND_FREE, PlayerDead); }