void detectKeys() { unsigned int *playerBottom[3] = {&g_worldGrid[charLocation.X][charLocation.Y],&g_worldGrid[charLocation.X - 1][charLocation.Y],&g_worldGrid[charLocation.X + 1][charLocation.Y]}; for( unsigned int w =0 ; w<3 ; ++w) { if(*playerBottom[w]== '4') { if (inventoryManagement("Red Key", 1)) { *playerBottom[w] = ' '; printMessages("You have picked up a Red Key!"); } playMusic(2); } else if(*playerBottom[w] == '5') { if (inventoryManagement("Blue Key", 1)) { *playerBottom[w] = ' '; printMessages("You have picked up a Blue Key!"); } playMusic(2); } else if(*playerBottom[w] == '6') { if (inventoryManagement("Green Key", 1)) { *playerBottom[w] = ' '; printMessages("You have picked up a Green Key!"); } playMusic(2); } } }
void initGame(int stg) { status = IN_GAME; initShip(); initShots(); initFoes(); initFrags(); initBonuses(); initBackground(); initBarrages(stagePrm[stg][0], stagePrm[stg][1], stagePrm[stg][2]); initGameState(stg); if ( stg < STAGE_NUM ) { setStageBackground(stg%5+1); playMusic(stg%5+1); } else { if ( !insane ) { setStageBackground(0); playMusic(0); } else { setStageBackground(6); playMusic(6); } } }
/* * Just starts a new level */ void startLevel() { pieceCount = 0x00; gamePaused = 0x01; // annimation beetween levels // there is two annimations to show: // - a simple shift of the last image to left // - a shift to left with a men pushing if (level % 4 == 0 && level != 0) { playMusic(2); pushLeftAll(displayField); rollNumber('l', level, 10, 1000); rollNumber('p', score, 10, 1000); } else { shiftLeftAll(displayField); } playMusic(0); delay(1900); playMusic(3); generateField(); // new field generatePiece(); // new piece addPiece(); // adds the new piece to fild updateDisplayField(); // updates the display field limit = 0x11; // sets the checkLines limit to default gamePaused = 0x00; }
int Imuse::setMusicSequence(int seqId) { int l, num = -1; if (seqId == -1) return _seqMusicTable[_curMusicSeq].soundId; if (seqId == 0) seqId = 2000; for (l = 0; _seqMusicTable[l].soundId != -1; l++) { if (_seqMusicTable[l].soundId == seqId) { num = l; break; } } assert(num != -1); Debug::debug(Debug::Imuse, "Imuse::setMusicSequence(): SoundId %d, filename: %s", _seqMusicTable[l].soundId, _seqMusicTable[l].filename); if (_curMusicSeq == num) return _seqMusicTable[_curMusicSeq].soundId; if (num) { playMusic(&_seqMusicTable[num], 0, true); } else { playMusic(&_stateMusicTable[_curMusicState], _curMusicState, true); num = 0; } _curMusicSeq = num; return _seqMusicTable[_curMusicSeq].soundId; }
void lvlIntro(Game *game, Level *level) { char levelNumber[50]; int row,col,xPos, j = 0; sprintf(levelNumber, "LEVEL %d", game->levelNum); playMusic(intro, FALSE); // Draw stars, increasing length (speeding up) for ( j = 0; j < 30; j++ ) { lcd_fillScreen(BLACK); for (row = level->stars.y; row < DISPLAY_HEIGHT; row += STAR_SPACING_HEIGHT) { for (col = level->stars.x; col < DISPLAY_WIDTH; col++) { if (xPos%STAR_SPACING_WIDTH == 0) { vLine(col,row, row + j, WHITE); } xPos++; } } xPos=0; // reset xPos lcd_putString(100, 50, (unsigned char *)levelNumber); drawShip(level->player.currPos.x, -3*j + INIT_SHIP_POS_Y, level->player.type); memcpy((char*)LCD_FRAME_BUFFER,(char*)LCD_TEMP_BUFFER, 153600); // write temp buffer to fram buffer } lcd_fillScreen(WHITE); playMusic(RainPizz,FALSE); memcpy((char*)LCD_FRAME_BUFFER,(char*)LCD_TEMP_BUFFER, 153600); // write temp buffer to fram buffer mdelay(150); // Draw stars, decreasing length (slowing down) for ( j = 15; j > 0; j-- ) { lcd_fillScreen(BLACK); for (row = level->stars.y; row < DISPLAY_HEIGHT; row += STAR_SPACING_HEIGHT) { for (col = level->stars.x; col < DISPLAY_WIDTH; col++) { if (xPos%STAR_SPACING_WIDTH == /*(row%2)*/ 0) { vLine(col,row, row + j, WHITE); } xPos++; } } xPos=0; // reset xPos lcd_putString(100, 50, (unsigned char *)levelNumber); drawShip(level->player.currPos.x, level->player.currPos.y - j*j, level->player.type); memcpy((char*)LCD_FRAME_BUFFER,(char*)LCD_TEMP_BUFFER, 153600); // write temp buffer to fram buffer mdelay(100); } }
void IgorEngine::PART_04() { if (_objectsState[106] == 1) { _currentPart = 730; playMusic(1); return; } if (_objectsState[107] == 1) { _objectsState[107] = 0; _currentPart = 750; playMusic(1); return; } _gameState.enableLight = 1; loadRoomData(PAL_Map, IMG_Map, BOX_Map, MSK_Map, TXT_Map); loadActionData(DAT_Map); _roomDataOffsets = PART_04_ROOM_DATA_OFFSETS; SET_EXEC_ACTION_FUNC(1, &IgorEngine::PART_04_EXEC_ACTION); PART_04_CLEAR_OBJECT_STATE_84(255); memcpy(_screenVGA, _screenLayer1, 46080); fadeInPalette(768); _currentAction.verb = kVerbWalk; if (_gameState.musicNum != 2) { playMusic(2); } _walkData[0].x = 160; _walkData[0].y = 133; _walkData[0].scaleWidth = 49; _walkData[0].scaleHeight = 49; _walkDataLastIndex = 1; _walkDataCurrentIndex = 1; enterPartLoop(); while (_currentPart == 40) { handleRoomInput(); if (compareGameTick(19, 32)) { handleRoomDialogue(); } if (compareGameTick(4, 8)) { handleRoomInventoryScroll(); } scrollPalette(200, 207); setPaletteRange(200, 207); if (compareGameTick(1)) { handleRoomLight(); } scrollPalette(184, 199); setPaletteRange(184, 199); waitForTimer(); } leavePartLoop(); fadeOutPalette(624); }
/** * Check if music is still playing. * If not, select the next track in the playlist and play it */ void SoundHandler::checkMusic() { if (_midiPlayer->isPlaying()) return; for (int i = 0; _vm->_defltTunes[i] != -1; i++) { if (_vm->_defltTunes[i] == _vm->getGameStatus().song) { if (_vm->_defltTunes[i + 1] != -1) playMusic(_vm->_defltTunes[i + 1]); else playMusic(_vm->_defltTunes[0]); break; } } }
void MainWindow::onTimer_timeout() { if (!soundEngine.isPlayingMusic()) { if (checkRepeat->isChecked()) { playMusic(sCurrentMusic,dDuration); } else { sliderMusic->setValue(sliderMusic->maximum()); labelPosition->setText(QApplication::translate("mainWindow","0:00/0:00",0)); buttonMusic->setText(QApplication::translate("mainWindow","&Play",0)); timer->stop(); } } // calculate the percentage of the music played iTimerCount++; if (!sliderMusic->isSliderDown()) { // we move the slider only if the user is not moving it manually double dPosition = (double)iTimerCount/TICK; sliderMusic->setValue(floor(dPosition/dDuration*sliderMusic->maximum())); } }
void MainWindow::on_buttonMusic_clicked() { if (soundEngine.isPlayingMusic()) { if (soundEngine.isMusicPaused()) { timer->start(); soundEngine.resumeMusic(); buttonMusic->setText(QApplication::translate("mainWindow","&Pause",0)); } else { timer->stop(); soundEngine.pauseMusic(); buttonMusic->setText(QApplication::translate("mainWindow","&Resume",0)); } } else { // we play the selected song (if it is a sound item) QTreeWidgetItem *qItem = treeMusic->currentItem(); if (qItem != NULL) { Item *item = dynamic_cast<QCustomTreeWidgetItem*>(qItem)->branch()->item(); if (item->type()==Item::tSound) { SoundItem *sItem = dynamic_cast<SoundItem*>(item); playMusic(sItem->fileName(),sItem->duration()); } } timer->start(); } }
void lvlOutro(Game *game, Level *level, Controller *userInput) { char title[50]; char score[50]; char livesLeft[50]; char hitRatioPercent[50]; char print = FALSE; float hitRatio = (float)level->hits/(float)level->numberOfFires; playMusic(theme2,TRUE); game->score *= hitRatio; sprintf(title, "LEVEL %d PERFORMANCE", game->levelNum); sprintf(score, "Score: %d", game->score); sprintf(livesLeft, "Remaining lives: %d", level->player.lives); sprintf(hitRatioPercent, "Hit and Miss Ratio: %.2lf%%", hitRatio*100); while(!userInput->start) { // wait for start button lcd_fillScreen(BLACK); lcd_putString( 50, 50, (unsigned char *)title ); lcd_putString(50, 100, (unsigned char *)score); lcd_putString(50, 110, (unsigned char *)livesLeft); lcd_putString(50, 120, (unsigned char *)hitRatioPercent); if(game->seed%10 == 0) { print = !print; } if(print) { lcd_putString(50, 300, "Press START to continue..."); } game->seed++; pollController(userInput); memcpy((char*)LCD_FRAME_BUFFER,(char*)LCD_TEMP_BUFFER, 153600); // write temp buffer to fram buffer } }
void Imuse::setMusicState(int stateId) { int l, num = -1; if (stateId == 0) stateId = 1000; for (l = 0; _stateMusicTable[l].soundId != -1; l++) { if (_stateMusicTable[l].soundId == stateId) { num = l; break; } } assert(num != -1); if (gDebugLevel == DEBUG_IMUSE || gDebugLevel == DEBUG_ALL) printf("Imuse::setMusicState(): SoundId %d, filename: %s\n", _stateMusicTable[l].soundId, _stateMusicTable[l].filename); if (_curMusicState == num) return; if (!_curMusicSeq) { playMusic(&_stateMusicTable[num], num, false); } _curMusicState = num; }
bool Music::loadSong(int songNumber) { debugC(kDebugLevelMusic, "Music: loadSong()"); if(songNumber == 100) songNumber = 55; else if(songNumber == 70) songNumber = 54; if((songNumber > 60) || (songNumber < 1)) return false; songNumber = ROOM_SONG[songNumber]; if(songNumber == 0) songNumber = 12; if((songNumber > NUM_SONGS) || (songNumber < 1)) return false; Common::String songName = Common::String(SONG_NAMES[songNumber - 1]); freeSong(); // free any song that is currently loaded stopMusic(); if (!playMusic(songName)) return false; startSong(); return true; }
GameStart::GameStart(){ setType("GameStart"); //dragonfly managers needed for this df::ResourceManager &resource_manager = df::ResourceManager::getInstance(); //setup GameOversprite df::Sprite *p_temp_sprite = resource_manager.getSprite("gamestart"); if (!p_temp_sprite){ df::LogManager &log_manager = df::LogManager::getInstance(); log_manager.writeLog("GameStart::GameStart(): Warning! Sprite '%s' not found", "gamestart"); } else{ setSprite(p_temp_sprite); setSpriteSlowdown(30); setTransparency('#'); } //put in center of window setLocation(df::CENTER_CENTER); //register interest registerInterest(df::KEYBOARD_EVENT); //play start music p_music = df::ResourceManager::getInstance().getMusic("start music"); playMusic(); df::WorldManager &world_manager = df::WorldManager::getInstance(); world_manager.setBoundary(df::Box(df::Position(), 250, 250)); }
void DosSoundMan_ns::playCharacterMusic(const char *character) { if (!character || locationHasOwnSoftMusic(_vm->_location._name)) { return; } char *name = const_cast<char*>(character); const char *newMusicFile = 0; if (!scumm_stricmp(name, _dinoName)) { newMusicFile = "dino"; } else if (!scumm_stricmp(name, _donnaName)) { newMusicFile = "donna"; } else if (!scumm_stricmp(name, _doughName)) { newMusicFile = "nuts"; } else { warning("unknown character '%s' in DosSoundMan_ns_ns::playCharacterMusic", character); return; } if (!_playing || (newMusicFile && scumm_stricmp(newMusicFile, _musicFile))) { // avoid restarting the same piece setMusicFile(newMusicFile); playMusic(); debugC(2, kDebugExec, "changeLocation: started character specific music (%s)", newMusicFile); } }
Sound::Sound() : currentMusic(0) { assert( soundPtr == 0); soundPtr = this; loaderThread = 0; //Load Sound audioOpen = false; /* Open the audio device */ if (Mix_OpenAudio( MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, 2048) < 0) { fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError()); return; } else { audioOpen = true; loaderThread = SDL_CreateThread(soundThread, this); } setMusicVolume(getConfig()->musicVolume); setSoundVolume(getConfig()->soundVolume); // for now... //playMusic("01 - pronobozo - lincity.ogg"); playMusic( getConfig()->playSongName ); }
void Audio::stopSpecial() { if (!specialId) return; int tmp = musiqueId; musiqueId = 0; specialId = 0; playMusic(tmp); }
void CSong::loadSong(const QString & filename) { CNote::setChannelHands(-2, -2); // -2 for not set -1 for none m_songTitle = filename; int index = m_songTitle.lastIndexOf("/"); if (index >= 0) m_songTitle = m_songTitle.right( m_songTitle.length() - index - 1); QString fn = filename; #ifdef _WIN32 fn = fn.replace('/','\\'); #endif m_midiFile->setLogLevel(3); m_midiFile->openMidiFile(string(fn.toLatin1())); ppLogInfo("Opening song %s", string(fn.toLatin1()).c_str()); transpose(0); midiFileInfo(); m_midiFile->setLogLevel(99); playMusic(false); rewind(); setPlayFromBar(0.0); setLoopingBars(0.0); setEventBits(EVENT_BITS_playingStopped); if (!m_midiFile->getSongTitle().isEmpty()) m_songTitle = m_midiFile->getSongTitle(); }
void Imuse::setMusicState(int stateId) { int l, num = -1; if (stateId == 0) stateId = 1000; for (l = 0; _stateMusicTable[l].soundId != -1; l++) { if (_stateMusicTable[l].soundId == stateId) { num = l; break; } } assert(num != -1); Debug::debug(Debug::Imuse, "Imuse::setMusicState(): SoundId %d, filename: %s", _stateMusicTable[l].soundId, _stateMusicTable[l].filename); if (_curMusicState == num) return; if (!_curMusicSeq) { playMusic(&_stateMusicTable[num], num, false); } _curMusicState = num; }
void MainMenuState::onEnter(){ if (!playMusic("audio/main_menu_audio.wav.ogg")){ std::cout << "main menu background music can't be loaded\n"; } }
void AudioMixer::fadeToTrack(string newTrackName, float crossfadeLength, float newMaxVolume, bool loop) { if(m_audioLoader->getMusic(newTrackName) == nullptr || m_currentTrack == nullptr) {return;} else if(m_currentTrack->getStatus() == sf::Sound::Stopped) { playMusic(newTrackName, crossfadeLength, 0.0f, 100.0f, loop); return; } float timeLeft = m_currentTrack->getDuration().asSeconds() - m_currentTrack->getPlayingOffset().asSeconds(); if(timeLeft < crossfadeLength) { crossfadeLength = timeLeft; } m_crossfadeInfo.isCrossfading = true; m_crossfadeInfo.crossfadePosition = 0.0f; /*if(!SettingsManager::getGlobalSettings()->SOUND_MUSIC) {_crossfadeInfo.maxVolume = 0.0f;} else{}*/ m_crossfadeInfo.maxVolume = newMaxVolume; m_crossfadeInfo.shouldLoop = loop; m_crossfadeInfo.crossfadeLength = crossfadeLength; m_nextTrackName = newTrackName; m_crossfadeClock.restart(); m_nextTrack = m_audioLoader->getMusic(newTrackName); m_nextTrack->setVolume(0.0f); m_nextTrack->play(); }
void Game::displayTitleBitmap() { loadWGP("..\\menu\\nointro.wgp"); playMusic("..\\midi\\title.mid"); _stub->setPalette(_bitmapBuffer0 + kOffsetBitmapPalette, 256); _stub->copyRect(0, 0, kGameScreenWidth, kGameScreenHeight, _bitmapBuffer1.bits, _bitmapBuffer1.pitch); _stub->copyRectWidescreen(kGameScreenWidth, kGameScreenHeight, _bitmapBuffer1.bits, _bitmapBuffer1.pitch); }
//////////////////////////////////////////////////////////// /// Entry point of application /// /// \return Application exit code /// //////////////////////////////////////////////////////////// int main() { // Play a sound playSound(); // Play music from an ogg file playMusic("orchestral.ogg"); // Play music from a flac file playMusic("ding.flac"); // Wait until the user presses 'enter' key std::cout << "Press enter to exit..." << std::endl; std::cin.ignore(10000, '\n'); return EXIT_SUCCESS; }
void MainMenu::draw(){ playMusic(MAINMENU); glPushMatrix(); /* ALWAYS START AT UPPER LEFT CORNER -> LOWER LEFT CORNER -> LOWER RIGHT CORNER -> UPPER RIGHT */ glBegin(GL_QUADS); glColor3f(0.85f,0.85f,0.85f); glVertex3f(-1*(this->width/2.0),(this->height/2.0),0); /* |\ */ glVertex3f(-1*(this->width/2.0),-1*(this->height/2.0),0); /* | | */ glVertex3f(-1*(this->width/2.0)+(this->percentBorder*(this->height)),-1*(this->height/2.0)+(this->percentBorder*(this->height)),0); /* |/ */ glVertex3f(-1*(this->width/2.0)+(this->percentBorder*(this->height)),(this->height/2.0)-(this->percentBorder*(this->height)),0); glEnd(); glBegin(GL_QUADS); glColor3f(0.80f,0.80f,0.80f); glVertex3f(-1*(this->width/2.0),(this->height/2.0),0); /*_____ */ glVertex3f(-1*(this->width/2.0)+(this->percentBorder*(this->height)),(this->height/2.0)-(this->percentBorder*(this->height)),0); /*\ / */ glVertex3f((this->width/2.0)-(this->percentBorder*(this->height)),(this->height/2.0)-(this->percentBorder*(this->height)),0); /* --- */ glVertex3f((this->width/2.0),(this->height/2.0),0); glEnd(); glBegin(GL_QUADS); glColor3f(0.75f,0.75f,0.75f); glVertex3f(-1*(this->width/2.0)+(this->percentBorder*(this->height)),(this->height/2.0)-(this->percentBorder*(this->height)),0); /*_____ */ glVertex3f(-1*(this->width/2.0)+(this->percentBorder*(this->height)),-1*(this->height/2.0)+(this->percentBorder*(this->height)),0); /*| | */ glVertex3f((this->width/2.0)-(this->percentBorder*(this->height)),-1*(this->height/2.0)+(this->percentBorder*(this->height)),0); /*----- */ glVertex3f((this->width/2.0)-(this->percentBorder*(this->height)),(this->height/2.0)-(this->percentBorder*(this->height)),0); glEnd(); glBegin(GL_QUADS); glColor3f(0.45f,0.45f,0.45f); glVertex3f(-1*(this->width/2.0)+(this->percentBorder*(this->height)),-1*(this->height/2.0)+(this->percentBorder*(this->height)),0); /* ___ */ glVertex3f(-1*(this->width/2.0),-1*(this->height/2.0),0); /*/ \ */ glVertex3f((this->width/2.0),-1*(this->height/2.0),0); /*----- */ glVertex3f((this->width/2.0)-(this->percentBorder*(this->height)),-1*(this->height/2.0)+(this->percentBorder*(this->height)),0); glEnd(); glBegin(GL_QUADS); glColor3f(0.40f,0.40f,0.40f); glVertex3f((this->width/2.0)-(this->percentBorder*(this->height)),(this->height/2.0)-(this->percentBorder*(this->height)),0); /* /| */ glVertex3f((this->width/2.0)-(this->percentBorder*(this->height)),-1*(this->height/2.0)+(this->percentBorder*(this->height)),0); /* | | */ glVertex3f((this->width/2.0),-1*(this->height/2.0),0); /* \| */ glVertex3f((this->width/2.0),(this->height/2.0),0); glEnd(); for(int i=0;i<NUM_IMAGES;i++){ if(this->images[i]){ this->images[i]->draw(); } } for(int i=0;i<NUM_ARROW_BUTTONS;i++){ if(this->arrowsbutton[i]){ this->arrowsbutton[i]->draw(); } } for(int x=0;x<NUM_BUTTON;x++){ if(this->buttons[x]){ this->buttons[x]->draw(); } } glPopMatrix(); }
void initMusic(void) { unsigned int version; result = FMOD_System_Create(&sys); ERRCHECK(result); result = FMOD_System_GetVersion(sys, &version); ERRCHECK(result); if (version < FMOD_VERSION) { return; } result = FMOD_System_Init(sys, 1, FMOD_INIT_NORMAL, NULL); ERRCHECK(result); sounds = (FMOD_SOUND **)malloc(SCNT*sizeof(FMOD_SOUND *)); result = FMOD_System_CreateSound(sys, "media/scienceisfun.mp3", FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM, 0, &(sounds[0])); ERRCHECK(result); // Log("sound 1 of 12 loaded\n"); result = FMOD_System_CreateSound(sys, "media/concentrationenhancingmenuinitialiser.mp3", FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM, 0, &(sounds[1])); ERRCHECK(result); // Log("sound 2 of 12 loaded\n"); result = FMOD_System_CreateSound(sys, "media/999999.mp3", FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM, 0, &(sounds[2])); ERRCHECK(result); // Log("sound 3 of 12 loaded\n"); result = FMOD_System_CreateSound(sys, "media/thecourtesycall.mp3", FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM, 0, &(sounds[3])); ERRCHECK(result); // Log("sound 4 of 12 loaded\n"); result = FMOD_System_CreateSound(sys, "media/technicaldifficulties.mp3", FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM, 0, &(sounds[4])); ERRCHECK(result); // Log("sound 5 of 12 loaded\n"); result = FMOD_System_CreateSound(sys, "media/overgrowth.mp3", FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM, 0, &(sounds[5])); ERRCHECK(result); // Log("sound 6 of 12 loaded\n"); result = FMOD_System_CreateSound(sys, "media/ghostofrattman.mp3", FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM, 0, &(sounds[5])); ERRCHECK(result); // Log("sound 7 of 12 loaded\n"); result = FMOD_System_CreateSound(sys, "media/hauntedpanels.mp3", FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM, 0, &(sounds[7])); ERRCHECK(result); // Log("sound 8 of 12 loaded\n"); result = FMOD_System_CreateSound(sys, "media/thefuturestartswithyou.mp3", FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM, 0, &(sounds[8])); ERRCHECK(result); // Log("sound 9 of 12 loaded\n"); result = FMOD_System_CreateSound(sys, "media/theresheis.mp3", FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM, 0, &(sounds[9])); ERRCHECK(result); // Log("sound 10 of 12 loaded\n"); result = FMOD_System_CreateSound(sys, "media/youknowher.mp3", FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM, 0, &(sounds[10])); ERRCHECK(result); // Log("sound 11 of 12 loaded\n"); result = FMOD_System_CreateSound(sys, "media/thefriendlyfaithplate.mp3", FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM, 0, &(sounds[11])); ERRCHECK(result); // Log("sound 12 of 12 loaded\n"); current_track = (rand() % SCNT); playMusic(current_track); }
void Sound::init() { // Don't initialize sound engine twice if (mInstalled) return; logger->log1("Sound::init() Initializing sound..."); mPlayBattle = config.getBoolValue("playBattleSound"); mPlayGui = config.getBoolValue("playGuiSound"); mPlayMusic = config.getBoolValue("playMusic"); config.addListener("playBattleSound", this); config.addListener("playGuiSound", this); config.addListener("playMusic", this); config.addListener("sfxVolume", this); config.addListener("musicVolume", this); if (SDL_InitSubSystem(SDL_INIT_AUDIO) == -1) { logger->log1("Sound::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("Sound::init Could not initialize audio: %s", Mix_GetError()); return; } Mix_AllocateChannels(16); Mix_VolumeMusic(mMusicVolume); Mix_Volume(-1, mSfxVolume); info(); mInstalled = true; if (!mCurrentMusicFile.empty() && mPlayMusic) playMusic(mCurrentMusicFile); }
bool Menu::loop(int ptype, SDL_Rect prect, SDL_Event* e) { // clear(); type = ptype; rect = prect; // init(); Uint32 fps = 0; bool quit = false; int done = false; if (type == TITLE) { playMusic(); } else if (type == STORE) { pauseType = PSTORE; if (resetStore) { createStore(); resetStore = false; } } else { pauseType = MAIN; pausePos = title.size(); } while (!quit && !done) { if(!Window::isVSync()) fps = SDL_GetTicks(); while (SDL_PollEvent(e) != NULL && !done) { switch (e->type) { case SDL_QUIT: quit = true; break; //case SDL_WINDOWEVENT: // Window::handleEvent(e); // break; default: done = handleEvent(e); break; } } render(); if (done == -1) quit = true; if(!Window::isVSync()) if (1000 / Game::FPS > SDL_GetTicks() - fps) SDL_Delay((1000 / Game::FPS) - (SDL_GetTicks() - fps)); } return quit; }
void Ultra::play() { float volume = 0.0; FMOD_Channel_SetVolume(musicChannel, 1.0); FMOD_Channel_GetVolume(musicChannel, &volume); fout << volume << std::endl; playMusic(ultraMusic); setCurrentGamePiece(createNewPiece()); setNextPiece(createNewPiece()); enableCurrentPiece(); setLinesCompleted(0); setLevel(1); setFallIterationDelay(computeFallIterationDelay()); setScore(0); setState(RUNNING); sf::Clock fallingClock; fallingClock.Reset(); float currentTime = 0, precTime = 0; while(renderArea->IsOpened()) { if(getState() == PAUSED) { setBackground(PAUSE_IMG); timer.pause(); if(handlePauseInput() == RETURN_MAIN) return; } else { timer.start(); currentTime = fallingClock.GetElapsedTime(); handleTimerInput(currentTime, precTime); handleUserInput(); if(Game::gameOver() || timeElapsed()) { if(handleGameOverInput() == RETURN_MAIN) return; } else render(); } renderArea->Display(); } }
void Title::handleFrameEvent() { // On fame 0, start the music and fade in if (getFrame() == 0) { playMusic(); _vm->_draw->forceBlit(); _vm->_palAnim->fade(_vm->_global->_pPaletteDesc, 0, 0); } }
/* * Just starts a new game */ void startGame() { level = 0; // reset level difficulty = 0; // reset difficulty level gameSpeed = 0; // reset game seep level timeEnd = pow(2, 5); // sets the time endo to default (2Hz) startLevel(); // starts a new level playMusic(3); // plays the tetris theme }
void AGOSEngine::o_playTune() { // 127: play tune uint16 music = getVarOrWord(); uint16 track = getVarOrWord(); if (music != _lastMusicPlayed) { _lastMusicPlayed = music; playMusic(music, track); } }