コード例 #1
0
ファイル: init.c プロジェクト: Syreniac/verdant-octo-spork
InitData initialise(void){
  /* This function will initialise the SDL library and create a blank window.
     I'll line by line comment what I'm doing here. */
  InitData initData;

  srand(time(NULL));

  /* Initialise SDL library (must be called before any other SDL_function),
  SDL_INIT_VIDEO flag initialise only the video SDL subsystem||SAM: audio must be called in a similar fashion||*/
  if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO) < 0)
  {
    /* If the SDL_Init function doesn't return -1, then something has gone wrong
    and we should probably close (after giving a helpful error message!) */
  	fprintf(stderr,"Could not initialize SDL: %s\n", SDL_GetError());
	fflush(stderr);
  	exit(1);
  }

  /* Now that SDL has been initialised by call SDL_Init, we can make the window
     The arguments are:
        - The window's name
        - X coords to open the window at (we don't need to specify something)
        - Y coords like above
        - The X size of the window in pixels
        - The Y size like above
        - SDL configuration options which can be found online in the API documentation*/
	/*Audio needs to be initialized at the very start too.*/
    TTF_Init();

  initData.graphicsData = createGraphicsData();

	audioSystem(&initData.audioData);


	loadMusic("sound/music01.wav" , 0, &initData.audioData);

	loadMusic("sound/music02.wav" , 1, &initData.audioData);

	loadMusic("sound/music03.wav" , 1, &initData.audioData);

	/*loadMusic("sound/music04.wav" , 1, &initData.audioData);*/
	
	loadSoundEffect("sound/returnFlower.wav", "returnFlower", &initData.audioData);

	loadSoundEffect("sound/thunder.wav", "thunder", &initData.audioData);

	loadSoundEffect("sound/garryScream.wav", "garryScream", &initData.audioData);

	loadSoundEffect("sound/applause.wav", "applause", &initData.audioData);

	loadSoundEffect("sound/winterComing.wav", "winterComing", &initData.audioData);
	
	
  return initData;
}
コード例 #2
0
ファイル: Game.cpp プロジェクト: bgradin/ChipsChallenge
void Game::loadSounds()
{
	string temp;
	bool changed = false;

	function<void (string, string)> loadSoundEffect = [&](string effectName, string defaultValue)
	{
		string effectFileName = saveData[effectName];

		if (effectFileName != "")
			soundEffects[effectName] = wav(effectFileName.c_str());
		else
		{
			changed = true;
			soundEffects[effectName] = wav((saveData[effectName] = defaultValue).c_str());
		}
	};

	loadSoundEffect("PickUpToolSound", "blip2.wav");
	loadSoundEffect("OpenDoorSound", "door.wav");
	loadSoundEffect("ChipDeathSound", "bummer.wav");
	loadSoundEffect("LevelCompleteSound", "ditty1.wav");
	loadSoundEffect("SocketSound", "chimes.wav");
	loadSoundEffect("BlockedMoveSound", "oof3.wav");
	loadSoundEffect("ThiefSound", "strike.wav");
	loadSoundEffect("SoundOnSound", "chimes.wav");
	loadSoundEffect("PickUpChipSound", "click3.wav");
	loadSoundEffect("SwitchSound", "pop2.wav");
	loadSoundEffect("SplashSound", "water2.wav");
	loadSoundEffect("BombSound", "hit3.wav");
	loadSoundEffect("TeleportSound", "teleport.wav");
	loadSoundEffect("TickSound", "click1.wav");
	
	if (changed)
		saveData.write();
}