enum ActionMenu StageMain(int *stageState, char *mapName) { static int bgm = - 1; static char name[MAX_PATH]; switch (*stageState) { case 0: map = ReadMap(mapName); #if !MAP_EDIT_MODE GetBgmName(name, mapName); bgm = LoadSound(name); #endif *stageState = 1; break; case 1: { InitMap(map); CreateObject(map); DrawMain = StageDraw; LoopSound(bgm); *stageState = 2; } break; case 2: MoveMap(map); MoveEnemy(map); MoveItem(map); MoveBomb(map); MoveEnemy(map); MovePlayer(map); if (IsPlayerDie()) { SoundPlay(res.sound_die); life--; if (life < 0) { FreeStage(map, stageState, bgm); return MENU_GAMEOVER; } *stageState = 1; } if (IsPlayerClear()) { FreeStage(map, stageState, bgm); return MENU_CLEAR; } break; } return MENU_STAGE; }
void ThrowObject::Throw( const Entity *owner, float speed, const Sentient *targetent, float gravity, float throw_damage ) { float traveltime; float vertical_speed; Vector target; Vector dir; Vector xydir; Event *e; e = new Event( EV_Detach ); ProcessEvent( e ); this->owner = owner->entnum; edict->ownerNum = owner->entnum; damage = throw_damage; target = targetent->origin; target.z += targetent->viewheight; setMoveType( MOVETYPE_BOUNCE ); setSolidType( SOLID_BBOX ); edict->clipmask = MASK_PROJECTILE; dir = target - origin; xydir = dir; xydir.z = 0; traveltime = xydir.length() / speed; vertical_speed = ( dir.z / traveltime ) + ( 0.5f * gravity * sv_currentGravity->value * traveltime ); xydir.normalize(); // setup ambient flying sound if ( throw_sound.length() ) { LoopSound( throw_sound.c_str() ); } velocity = speed * xydir; velocity.z = vertical_speed; angles = velocity.toAngles(); setAngles( angles ); avelocity.x = crandom() * 200.0f; avelocity.y = crandom() * 200.0f; takedamage = DamageYes; }
// Pass in the name of the song you want to loop, method must be checked every frame HRESULT SoundManager::LoopSound(char* songName) { int songNum = -1; // look for the song in out list of songs for(int i = 0; i < numOfFiles; i++) { char* fileName = songsLoaded[i]; if(strcmp(songName, fileName) == 0) { songNum = i; break; } } // Could not find the song so exit out of the method if(songNum == -1) return -1; LoopSound(songNum); return 0; }