Esempio n. 1
0
void Enemy1::loadData(std::string path)
{
	std::fstream jsonFile;
	jsonFile.open(path);
	if (jsonFile.is_open())
	{
		Document allData;
		std::string content((std::istreambuf_iterator<char>(jsonFile)), std::istreambuf_iterator<char>());
		allData.Parse(content.c_str());
		Value& enemyArr = allData["enemies"];
		Value& attr = enemyArr[enemyID];

		path_ = attr["texture"].GetString();
		MAX_HEALTH = attr["MAX_HEALTH"].GetInt();
		DAMAGE = attr["DAMAGE"].GetInt();
		CLIP_H = attr["CLIP_H"].GetInt();
		CLIP_W = attr["CLIP_W"].GetInt();

		animFrameSize.push_back(attr["WALKING_FRAMES_END"].GetInt());
		animFrameSize.push_back(attr["PUNCHING_FRAMES_END"].GetInt());
		animFrameSize.push_back(attr["FALLING_FRAMES_END"].GetInt());

		SHIFTING_PERCENTIGE = allData["SHIFTING_PERCENTIGE"].GetDouble();
		DIFF_BY_X_PERCENTIGE = allData["DIFF_BY_X_PERCENTIGE"].GetDouble();
		DIFF_BY_Y_PERCENTIGE = allData["DIFF_BY_Y_PERCENTIGE"].GetDouble();

		wooshSound = loadWAV(allData["wooshSound"].GetString());
		punchSound = loadWAV(allData["punchSound"].GetString());

		health = MAX_HEALTH;
		DEATH_FRAME = 4 * FRAMES_DELIMITOR;
	}
	else
	{
		printf("Error: Can't open file %s\n", path.c_str());
	}
	jsonFile.close();
}
Esempio n. 2
0
bool SoundDesc::load(SoundType type, byte *data, uint32 dSize) {
	free();

	switch (type) {
	case SOUND_ADL:
		return loadADL(data, dSize);
	case SOUND_SND:
		return loadSND(data, dSize);
	case SOUND_WAV:
		return loadWAV(data, dSize);
	}

	return false;
}
Esempio n. 3
0
		SoundEffectPtr ResourceLoader::load<SoundEffect>(std::string file){
			SoundEffectPtr res = nullptr;
			vector<char> delimiters(3);
			delimiters.push_back('.');
			delimiters.push_back('/');
			delimiters.push_back('\\');
			string file_ext = Utils::split(file,delimiters).back();

			if(file_ext == "wav"){
				res = loadWAV(file);
			}else{
				throw ServiceException("Unimplemented resource loader");
			}

			return res;
		}
Esempio n. 4
0
OPAL_SOUND_MGR int SoundManager::loadAudioInToSystem( std::string filename )
{
	if ( filename.empty() )
		return -1;

	// Make sure we have audio buffers available
	if ( mAudioBuffersInUseCount == MAX_AUDIO_BUFFERS ) return -1;

	// Find a free Audio Buffer slot
	int bufferID = 0;      // Identity of the Sound Buffer to use

	while ( mAudioBufferInUse[ bufferID ] == true ) bufferID++;

	// load .wav, .ogg or .au
	if ( filename.find( ".wav", 0 ) != std::string::npos )
	{
		printf(" ---> found Wav\n");
		// When you are here, bufferID now represents a free Audio Buffer slot
		// Attempt to load the SoundFile into the buffer
		if ( !loadWAV( filename, mAudioBuffers[ bufferID ] ) ) return -1;
	}
	else if ( filename.find( ".ogg", 0 ) != std::string::npos )
	{
		printf(" ---> found ogg\n");
		std::cout<<filename<<std::endl;
		if ( !loadOGG( filename, mAudioBuffers[bufferID ]) ) return -1;

	}
	else if ( filename.find( ".au", 0 ) != std::string::npos )
	{
		printf(" ---> found au\n");
		// TODO if ( !loadAU( filename, mAudioBuffers[mBufferID]) ) return -1;
	}

	// Successful load of the file into the Audio Buffer.
	mAudioBufferInUse[ bufferID ] = true;      // Buffer now in use
	mAudioBufferFileName[bufferID]=filename;   // save the file descriptor


	mAudioBuffersInUseCount++;               // bump the 'in use' counter

	return bufferID;
}