示例#1
0
文件: SoundFX.cpp 项目: vsrz/VHH
void SoundFX::Initialize()
{
	attack1_snd.loadFromFile("./Resources/Sounds/Battle/Player_attack1.wav");
	attack_sounds[0].setBuffer(attack1_snd);
	attack2_snd.loadFromFile("./Resources/Sounds/Battle/Player_attack2.wav");
	attack_sounds[1].setBuffer(attack2_snd);
	attack3_snd.loadFromFile("./Resources/Sounds/Battle/Player_attack3.wav");
	attack_sounds[2].setBuffer(attack3_snd);

	hit1_snd.loadFromFile("./Resources/Sounds/Battle/Player_hit1.wav");
	hit_sounds[0].setBuffer(hit1_snd);
	hit2_snd.loadFromFile("./Resources/Sounds/Battle/Player_hit2.wav");
	hit_sounds[1].setBuffer(hit2_snd);

	miss1_snd.loadFromFile("./Resources/Sounds/Battle/Player_miss1.wav");
	hit_sounds[0].setBuffer(miss1_snd);
	miss2_snd.loadFromFile("./Resources/Sounds/Battle/Player_miss2.wav");
	hit_sounds[1].setBuffer(miss2_snd);

	burp1_snd.loadFromFile("./Resources/Sounds/Battle/Player_burp1.wav");
	burp2_snd.loadFromFile("./Resources/Sounds/Battle/Player_burp2.wav");
	burp3_snd.loadFromFile("./Resources/Sounds/Battle/Player_burp3.wav");
	burp_sounds[0].setBuffer(burp1_snd);
	burp_sounds[1].setBuffer(burp2_snd);
	burp_sounds[2].setBuffer(burp3_snd);
}
示例#2
0
int InitGL()					 // All Setup For OpenGL goes here
{
	glShadeModel(GL_SMOOTH);		 // Enables Smooth Shading
    glClearColor(0.0, 0.0, 0.0, 1.0);
	glClearDepth(1.0f);				// Depth Buffer Setup
	glEnable(GL_DEPTH_TEST);		// Enables Depth Testing
	glDepthFunc(GL_LEQUAL);			// The Type Of Depth Test To Do
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// Really Nice Perspective Calculation
    
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);    // Uses default lighting parameters
	glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
	glEnable(GL_NORMALIZE);
    
	glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);
	glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);
	glLightfv(GL_LIGHT1, GL_POSITION, LightPosition);
	glEnable(GL_LIGHT1);
    
    glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
    
    // and now some init I need to do for other stuff
    
    ilInit(); /* Initialization of DevIL */
    
    // mouse stuff
    pointer = toGLTexture("./dati/models/textures/mirino.png");
	lastx = middleX;
    lasty = middleY;
    relativeX = 0.0;
    relativeY = 0.0;
    glutWarpPointer(middleX, middleY); // put the cursor in the middle of the screen
    
	//for the menu

	InitMenu();

    // for the text
    
    t3dInit();
    
    // for the skybox
    
    initSkybox();
    
    // for the blend
    
    initAssets();

	// for the sounds
    if (!sound_hit.loadFromFile("./dati/audio/hit.wav")) return -1;
	if (!sound_miss.loadFromFile("./dati/audio/miss.wav")) return -1;
	if (!sound_youreempty.loadFromFile("./dati/audio/youreempty.wav")) return -1;
	if (!sound_ohno.loadFromFile("./dati/audio/ohno.wav")) return -1;
	music.setLoop(true);
	if (!music.openFromFile("./dati/audio/Rango_Theme.ogg")) return -1;
	music.play();
    
	return TRUE;					// Initialization Went OK
}
示例#3
0
  bool SoundHandler::LoadFromFile(const typeAssetID theAssetID, sf::SoundBuffer& theAsset)
  {
    // Start with a return result of false
    bool anResult = false;

    // Retrieve the filename for this asset
    std::string anFilename = GetFilename(theAssetID);

    // Was a valid filename found? then attempt to load the asset from anFilename
    if(anFilename.length() > 0)
    {
      // Load the asset from a file
#if (SFML_VERSION_MAJOR < 2)
      anResult = theAsset.LoadFromFile(anFilename);
#else
      anResult = theAsset.loadFromFile(anFilename);
#endif
    }
    else
    {
      ELOG() << "SoundHandler::LoadFromFile(" << theAssetID
        << ") No filename provided!" << std::endl;
    }

    // Return anResult of true if successful, false otherwise
    return anResult;
  }
示例#4
0
	virtual void init()
	
	
	{
		dt=0;
		select_switch = 0.2;
		
		if (!standard_font.loadFromFile("fonts/Unique.ttf"))
{
    // error...
}
	//	darken = sf::RectangleShape(sf::Vector2f(800,400));
		
//sfx
if (!buffer.loadFromFile("sfx/Blip 007.wav"))

{
     //error
}
blip.setBuffer(buffer);


		if(!title.loadFromFile("gfx/title.png"))std::cout<<"Error"<<std::endl;

		t**s.setTexture(title);
		t**s.setOrigin(50,8);
		t**s.setScale(sf::Vector2f(3,3));
		t**s.setPosition(400,100);
		
		sf::FloatRect tempt ;
		
		for(int i =0 ; i<4;i++)
		{
			selector[i].setFont(standard_font);
			selector[i].setCharacterSize(28);
			 
		
		// dla centrowania obiektow
		
			tempt = selector[i].getGlobalBounds();
			selector[i].setOrigin(sf::Vector2f(tempt.width/2,tempt.height/2));
			
			selector[i].setPosition(350,150+30*i);
		}
		
		selector[0].setString("Start game");
		selector[1].setString("Info");
		selector[2].setString("Highscores");
		selector[3].setString("Exit");
		
		
		selector[0].setColor(sf::Color(0,127,127));
		
		timer.restart();
		
		};
bool SoundManager::load(Path name, sf::SoundBuffer & dst)
{
	if (name.str().find(internal_path) == 0) {
		return true;
	} else {
		DataManager::Paths paths = app->data.paths(Path("sounds") + name);
		paths.push_back(name);
		
		bool success = false;
		for (int i = 0; i < paths.size() && !success; i++) {
			success = dst.loadFromFile(paths[i].c_str());
		}
		
		if (success) {
			LOG(DEBUG,   "loaded sound '%s'", name.c_str());
		} else {
			LOG(WARNING, "unable to find sound '%s'", name.c_str());
		}
		return success;
	}
}
示例#6
0
  bool SoundHandler::loadFromFile(const typeAssetID assetID, sf::SoundBuffer& asset)
  {
    // Start with a return result of false
    bool succ = false;

    // Retrieve the filename for this asset
    std::string anFilename = assetID;

    // Was a valid filename found? then attempt to load the asset from anFilename
    if(anFilename.length() > 0)
    {
      // Load the asset from a file
      succ = asset.loadFromFile(anFilename);
    }
    else
    {
      ELOG() << "SoundHandler::loadFromFile(" << assetID
        << ") No filename provided!" << std::endl;
    }

    // Return anResult of true if successful, false otherwise
    return succ;
  }
示例#7
0
void chargerSound(sf::SoundBuffer& buffer, std::string filePath)
{
    if(!buffer.loadFromFile(filePath))
        std::cerr << "Erreur durant chargement du son " << filePath << std::endl;
}