/****************************************************************************** * * Creates 2D (stereo) source * ******************************************************************************/ EXPORT INT32 HWRAPI (Add2DSource) (sfx_data_t *sfx) { FSOUND_SAMPLE *fmsample = NULL; INT32 chan = -1; if (!sfx) return chan; fmsample = FSOUND_Sample_Load(FSOUND_FREE, INT2CHAR(sfx->data), FSOUND_DOOMLOAD, SFXLENGTH); if (fmsample) { if (!FSOUND_Sample_SetDefaults(fmsample, (INT32)((float)(*((UINT16 *)sfx->data+1)) * recalc_pitch(sfx->pitch)), sfx->volume == -1 ? 255 : sfx->volume, sfx->sep == NORMAL_SEP ? FSOUND_STEREOPAN : sfx->sep, sfx->priority)) DBG_Printf("FMOD(Add2DSource, FSOUND_Sample_SetDefaults, sfxid# %i): %s\n", sfx->id,FMOD_ErrorString(FSOUND_GetError())); if (!FSOUND_Sample_SetMode(fmsample,FSOUND_2D)) DBG_Printf("FMOD(Add2DSource, FSOUND_Sample_SetMode, sfxid# %i): %s\n", sfx->id,FMOD_ErrorString(FSOUND_GetError())); chan = FSOUND_PlaySoundEx(FSOUND_FREE,fmsample,NULL,true); if (chan == -1) { DBG_Printf("FMOD(Add2DSource, FSOUND_PlaySoundEx, sfxid# %i): %s\n", sfx->id,FMOD_ErrorString(FSOUND_GetError())); return chan; } #ifdef MORESTUFF else DBG_Printf("FMOD(Add2DSource, FSOUND_PlaySoundEx): sfxid# %i is playing on channel %i\n", sfx->id,chan); #endif } else { DBG_Printf("FMOD(Add2DSource,FSOUND_Sample_Load, sfxid# %i): %s\n", sfx->id,FMOD_ErrorString(FSOUND_GetError())); return chan; } if (FSOUND_GetCurrentSample(chan)) { if (!FSOUND_SetCurrentPosition(chan, 0)) DBG_Printf("FMOD(Add2DSource, FSOUND_SetCurrentPosition, channel %i, sfxid# %i): %s\n", chan,sfx->id,FMOD_ErrorString(FSOUND_GetError())); } return chan; }
int main ( int argc, char* args[] ) { init(); srand(time(NULL)); int FPS = 0; ///////GLOBAL LOADING tex_spikes = loadTexture("data/gfx/Spikes.png"); tex_block1 = loadTexture("data/gfx/block1.png"); tex_menu = loadTexture("data/gfx/menu.png"); tex_playgame = loadTexture("data/gfx/playgame.png"); tex_selectlevel = loadTexture("data/gfx/selectlevel.png"); tex_editor = loadTexture("data/gfx/editor.png"); tex_exit = loadTexture("data/gfx/exitmenu.png"); tex_player1 = loadTexture("data/gfx/player.png"); tex_door = loadTexture("data/gfx/door.png"); tex_font = loadTexture("data/gfx/font.png"); tex_done = loadTexture("data/gfx/ok.png"); tex_gold = loadTexture("data/gfx/gold.png"); tex_silver = loadTexture("data/gfx/silver.png"); tex_bronze = loadTexture("data/gfx/bronze.png"); tex_eyes = loadTexture("data/gfx/playgame.png"); tex_arrow = loadTexture("data/gfx/arrow.png"); tex_info = loadTexture("data/gfx/info.png"); ///////soundsss sample_playerJump = FSOUND_Sample_Load(FSOUND_UNMANAGED,"data/sfx/jump.wav",0,0,0); FSOUND_Sample_SetDefaults(sample_playerJump, -1,100,-1,-1); sample_playerHit = FSOUND_Sample_Load(FSOUND_UNMANAGED,"data/sfx/hit.wav",0,0,0); FSOUND_Sample_SetDefaults(sample_playerHit, -1,100,-1,-1); sample_playerForce = FSOUND_Sample_Load(FSOUND_UNMANAGED,"data/sfx/force.wav",0,0,0); FSOUND_Sample_SetDefaults(sample_playerForce, -1,100,-1,-1); song2 = FSOUND_Stream_Open( "data/music/Random-SitgesSavepoint.mp3",FSOUND_LOOP_NORMAL,0,0); FSOUND_Stream_Play( 1, song2 ); FSOUND_Stream_SetLoopCount(song2,-1); //FSOUND_SetVolume(1,80); std::ifstream file ("data/levels/score.lvl"); while ( !file.eof() ) { o_scores.push_back(new Score()); file >> o_scores.back()->i_number; file >> o_scores.back()->b_unlocked; file >> o_scores.back()->i_highScore; file >> o_scores.back()->i_B; file >> o_scores.back()->i_S; file >> o_scores.back()->i_G; } file.close(); //o_scores.pop_back(); gameState = new StateMenu(); currentGameState = STATE_MENU; /* for ( int n = 0; n < 100; n++ ) { o_scores.push_back( new Score () ); o_scores.back()->b_unlocked = true; o_scores.back()->i_highScore = 0; o_scores.back()->i_B = 0; o_scores.back()->i_G = 0; o_scores.back()->i_S = 0; }*/ //saving FPSA = SDL_GetTicks(); while ( nextGameState != STATE_EXIT ) { FPS = SDL_GetTicks(); gameState->handleEvents(); gameState->logic(); FPSA = SDL_GetTicks(); gameState->render(); changeGameState(); //////////////////////////// if ( (SDL_GetTicks() - FPS) < 1000/60 ) { //SDL_Delay( ( 1000/60) - (SDL_GetTicks() - FPS) ); } SDL_Delay(2); } FSOUND_Stream_Close(song2); FSOUND_Close(); return 0; }
EXPORT INT32 HWRAPI (Add3DSource) (source3D_data_t *src, sfx_data_t *sfx) { FSOUND_SAMPLE *fmsample = NULL; INT32 chan = -1; float pos[3]; float vel[3]; #ifdef MORESTUFF src->min_distance = MIN_DISTANCE; src->max_distance = MAX_DISTANCE; #endif pos[0] = src->pos.x; pos[1] = src->pos.z; pos[2] = src->pos.y; vel[0] = src->pos.momx; vel[1] = src->pos.momz; vel[2] = src->pos.momy; if (sfx) fmsample = FSOUND_Sample_Load(FSOUND_FREE, INT2CHAR(sfx->data), FSOUND_DOOMLOAD, SFXLENGTH); else fmsample = blankfmsample; if (fmsample) { if (sfx && !FSOUND_Sample_SetDefaults(fmsample, (INT32)((*((UINT16 *)sfx->data+1))*recalc_pitch(sfx->pitch)), (sfx->volume == -1 ? 255 : sfx->volume), (sfx->sep == NORMAL_SEP ? FSOUND_STEREOPAN : sfx->sep), (sfx->priority) ) ) DBG_Printf("FMOD(Add3DSource, FSOUND_Sample_SetDefaults, SFX's ID# %i): %s\n", sfx?sfx->id:0,FMOD_ErrorString(FSOUND_GetError())); #if 0 if (!FSOUND_Sample_SetMinMaxDistance(fmsample, src->min_distance, src->max_distance)) DBG_Printf("FMOD(Add3DSource, FSOUND_Sample_SetMinMaxDistance, SFX's ID# %i): %s\n", sfx?sfx->id:0,FMOD_ErrorString(FSOUND_GetError())); #endif chan = FSOUND_PlaySoundEx(FSOUND_FREE,fmsample,NULL,true); if (chan == -1) { DBG_Printf("FMOD(Add3DSource, FSOUND_PlaySoundEx, SFX's ID# %i): %s\n",sfx?sfx->id:0,FMOD_ErrorString(FSOUND_GetError())); return chan; } else { if (!sfx) DBG_Printf("FMOD(Add3DSource, Main): Added blank-sound added to channel %i\n",chan); #ifdef MORESTUFF else DBG_Printf("FMOD(Add3DSource, Main): Added sfxid# %i added to channel %i\n",sfx->id,chan); #endif } } else { if (sfx) DBG_Printf("FMOD(Add3DSource, FSOUND_Sample_Load, sfxid# %i): %s\n",sfx->id,FMOD_ErrorString(FSOUND_GetError())); else DBG_Printf("FMOD(Add3DSource, FSOUND_Sample_Alloc): %s\n", FMOD_ErrorString(FSOUND_GetError())); return chan; } if (FSOUND_GetCurrentSample(chan)) { if (!FSOUND_SetCurrentPosition(chan, 0)) DBG_Printf("FMOD(Add3DSource, FSOUND_SetCurrentPosition, channel %i, sfxid# %i): %s\n", chan,sfx?sfx->id:0,FMOD_ErrorString(FSOUND_GetError())); if (!FSOUND_3D_SetAttributes(chan,pos,vel)) DBG_Printf("FMOD(Add3DSource, FSOUND_3D_SetAttributes, channel %i, sfxid# %i): %s\n", chan,sfx?sfx->id:0,FMOD_ErrorString(FSOUND_GetError())); if (!FSOUND_SetReserved(chan, (signed char)src->permanent)) DBG_Printf("FMOD(Add3DSource, FSOUND_SetReserved, channel %i, sfxid# %i): %s\n", chan,sfx?sfx->id:0,FMOD_ErrorString(FSOUND_GetError())); if (src->head_relative) reladd(chan); } return chan; }