Exemplo n.º 1
0
  bool MusicHandler::LoadFromMemory(const typeAssetID theAssetID, sf::Music& theAsset)
  {
    // Start with a return result of false
    bool anResult = false;

    // TODO: Retrieve the const char* pointer to load data from
    const char* anData = NULL;
    // TODO: Retrieve the size in bytes of the font to load from memory
    size_t anDataSize = 0;

    // Try to obtain the font from the memory location specified
    if(NULL != anData && anDataSize > 0)
    {
      // Load the image from the memory location specified
#if (SFML_VERSION_MAJOR < 2)
      anResult = theAsset.OpenFromMemory(anData, anDataSize);
#else
      anResult = theAsset.openFromMemory(anData, anDataSize);
#endif
    }
    else
    {
      ELOG() << "MusicHandler::LoadFromMemory(" << theAssetID
        << ") Bad memory location or size!" << std::endl;
    }

    // Return anResult of true if successful, false otherwise
    return anResult;
  }
Exemplo n.º 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
}
Exemplo n.º 3
0
void newGame ()
{
	music.stop();
	music.openFromFile("./dati/audio/Morricone.ogg");
	music.play();
	main_camera.setLocRot(locRot(0,0,0,0,0,0));

    int j;
    
	t=reset_time(t);

    for(j=0; j<18; j++){
        m[j]=reset_motion(m[j]);
    }
    
    livello=1;
    
    // for the score
    
    score = 0;

	gun0.bullet_number = BULLET_NUMBER;
    
    first = TRUE;
    
    return;
}
Exemplo n.º 4
0
  bool MusicHandler::LoadFromFile(const typeAssetID theAssetID, sf::Music& 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.OpenFromFile(anFilename);
#else
      anResult = theAsset.openFromFile(anFilename);
#endif
    }
    else
    {
      ELOG() << "MusicHandler::LoadFromFile(" << theAssetID
        << ") No filename provided!" << std::endl;
    }

    // Return anResult of true if successful, false otherwise
    return anResult;
  }
void SoundEngine::playMusic(sf::Music & Music)
{
	if (activeMusic == true)
	{
		Music.setLoop(true);
		Music.setVolume(20);
		Music.play();
	}
}
Exemplo n.º 6
0
Arquivo: music.cpp Projeto: vsrz/VHH
void Music::Play(Music::Setting setting)
{
	switch(setting)
	{
	case MENU:
		menu_snd.play();
		battle_snd.stop();
		break;
	case BATTLE:
		menu_snd.stop();
		battle_snd.play();
		break;
	}
}
Exemplo n.º 7
0
void MouseClick(sf::RenderWindow &Window, sf::Music &introMusic)
{
    int mouseX = Window.GetInput().GetMouseX();
    int mouseY = Window.GetInput().GetMouseY();
    if(Window.GetInput().IsMouseButtonDown(sf::Mouse::Left) && mouseX >= 350 && mouseX <= 450)
    {
        if(mouseY > 100 && mouseY < 200)
            introMusic.Play();
        else if (mouseY > 200 && mouseY < 300)
            introMusic.Pause();
        else if (mouseY > 300 && mouseY < 400)
            introMusic.Stop();
    }
}
		void init(string path) {
			if ( !sound.openFromFile(path) ) {
				cout << "error loading music";
				return;
			}
			
		}
Exemplo n.º 9
0
	void HandleSound(){
		/* Handle sound_queue and music */

		if( SoundFx.getStatus() == 0 ){ //status : STOPPED
			if( !sound_queue.empty() ){
				SoundFx.openFromFile( *sound_queue.front() );
				SoundFx.play();

				sound_queue.pop();
			}
		}

		if( ::SoundMusic.getStatus() == 0 && now_log -> music_path.size() != 0 ){
			::SoundMusic.play();
		}
	}
Exemplo n.º 10
0
void levelChanger(void)
{
    if (score >= 100) {
		if(livello==3){
			//musica
			music.stop();
			music.openFromFile("./dati/audio/Stuck_In_Guacamole.ogg");
			music.play();
			menu_id=4;
		}
		else{
			changeLevel(UP);
			reload();
			score = 0;
		}
    }
    return;
}
Exemplo n.º 11
0
    static void tick()
    {
        if(currently_playing.getStatus() == sf::SoundSource::Stopped)
        {
            current_song++;

            swap_to_song_type(ROUND_GENERAL);
        }
    }
Exemplo n.º 12
0
Arquivo: music.cpp Projeto: vsrz/VHH
void Music::Initialize()
{
	menu_snd.openFromFile("./Resources/Sounds/menumusic.ogg");
	menu_snd.setVolume(60.0f);
	menu_snd.setLoop(true);
	battle_snd.openFromFile("./Resources/Sounds/battlemusic.ogg");
	battle_snd.setVolume(40.0f);
	battle_snd.setLoop(true);

	menu_snd.play();
}
Exemplo n.º 13
0
    static void swap_to_song_type(music_purpose new_purpose)
    {
        if(new_purpose == NONE)
        {
            currently_playing.stop();
            current_song = -1;
            return;
        }

        ///at the moment do shit
        int new_song = -1;

        for(int i=0; i<(int)file_names.size(); i++)
        {
            int song_offset = (i + current_song) % file_names.size();

            music_purpose current_purpose = (music_purpose)purpose[song_offset];

            if((current_purpose & new_purpose) > 0)
            {
                new_song = song_offset;
                break;
            }
        }

        if(new_song == -1)
            return;

        if(new_song == current_song && currently_playing.getStatus() != sf::SoundSource::Stopped)
            return;

        currently_playing.stop();

        currently_playing.openFromFile("res/" + file_names[new_song]);

        currently_playing.play();

        current_song = new_song;
    }
Exemplo n.º 14
0
	void ManageSound() {
		assert( now_log != 0 ); // null pointer is unexceptable and there is no solution

		//stop whatever Sound Effect playing right now
		SoundFx.stop();
		
		//empty the queue if there is still any member on the queue
		while( !sound_queue.empty() ) sound_queue.pop(); 

		for( unsigned i = 0; i < now_log -> soundFx_path.size(); ++i ){
			sound_queue.push( &(now_log->soundFx_path[i]) );
		}
		if( now_log -> music_path.size() != 0 ){
			SoundMusic.openFromFile( now_log -> music_path );
		}
	}
Exemplo n.º 15
0
	/*
		PRIVATE function are not supposed to be called from outside VisualNovel namespace
		even though it's accessible from global.
		it can lead to errors if called
	*/
	void Init(){
		//get the image for the text's background
		log_background = get_image( "resource/LogBackground.png" );

		//set the volume to the default global volume
		SoundFx.setVolume( MUSIC_VOLUME ); 
		
		static bool loaded = false;
		if( !loaded ) //to prevent double calling
		{
			font_display.loadFromFile( "resource/PTN57F.ttf" );

			log_text_display.setFont( font_display );
			log_text_display.setCharacterSize( 24 );
			log_text_display.setColor( sf::Color( 255, 255, 255 ) );
			log_text_display.setPosition( log_x + log_padding_x, log_y + log_padding_y );

			log_name_display.setFont( font_display );
			log_name_display.setCharacterSize( 40 );
			log_name_display.setColor( sf::Color( 255, 255, 255 ) );
			log_name_display.setPosition( log_x + log_padding_x, log_y - log_to_name_y - 40 );
		}
	}
Exemplo n.º 16
0
	void Music::SetVolume(float32 volume)
	{ music.setVolume(volume); }
Exemplo n.º 17
0
		void play(float _volume=1.0f)
		{
			setVolume(_volume);
			sound.play();
		}
Exemplo n.º 18
0
		void setVolume(float _volume=1.0f) {
			volume = _volume;
			int intVol = _volume*100.0f;
			sound.setVolume(intVol);
		}
Exemplo n.º 19
0
		void stop() {
			sound.stop();
		}
Exemplo n.º 20
0
		void setLoop(bool val) {
			sound.setLoop(val);
		}
Exemplo n.º 21
0
	bool Music::Load(const String& fileName)
	{ return music.openFromFile(fileName.ptr); }
Exemplo n.º 22
0
	float32 Music::GetDurationInSeconds()
	{ return music.getDuration().asSeconds(); }
Exemplo n.º 23
0
void TWindows :: ResumeMenu(sf::RenderWindow& oknoAplikacji, bool& skip, sf::Music& Gmusic, int TGmusic)
{
	while( oknoAplikacji.isOpen() )
	{
		//CZYSZCZENIE OKNA
		EventsWin(oknoAplikacji, tribe, option, skip, 1);
		if(skip==true)
			if(TGmusic!=-1)
			{
				Gmusic.stop();
			}
		sf::Texture textur;
			bool viewtext=textur.loadFromFile("tloczarne.png");
			if(viewtext==true)
			{
				sf::Sprite blackpic;
				blackpic.setColor(sf::Color(0, 0, 0, 125));
				blackpic.setTexture(textur);
				blackpic.setScale(10,10);
				oknoAplikacji.draw(blackpic);
			}

		sf::Font czcionka;
		sf::Text costam,costam1, costam2;
		if(czcionka.loadFromFile("XG-pixo.ttf"))
		{
			costam.setFont(czcionka);
		//TEXT W MENU TYTULOWYM
			costam.setString("*PAUSE*");
			costam.setCharacterSize(60);
			//costam.setStyle(sf::Text::Bold);
			costam.setPosition(100, 50);
			costam.setScale(2,2);
			costam.setColor(sf::Color(255,255,255)); 
			oknoAplikacji.draw(costam);

			//RESUME
			costam.setString("RESUME");
			costam.setCharacterSize(20);
			//costam.setStyle(sf::Text::Bold);
			costam.setPosition(295, 300);
			costam.setScale(2,2);
			if(option==0)
			{
				costam.setColor(sf::Color(125,125,125)); 
			}
			else 
			{
				costam.setColor(sf::Color(255,255,255)); 
			}
			oknoAplikacji.draw(costam);

			//EXIT
			costam.setString("EXIT");
			if(option==0)
			{
				costam.setColor(sf::Color(255,255,255)); 
			}
			else 
			{
				costam.setColor(sf::Color(125,125,125)); 
			}
			costam.setPosition(340, 350);
			oknoAplikacji.draw(costam);
			
		}
		oknoAplikacji.display();
		if(tribe==1 || skip==true)
			break;
	}
	oknoAplikacji.clear(sf::Color( 10, 10, 10 ));
	tribe=0;
	option=0;
}
Exemplo n.º 24
0
namespace music
{
    enum music_purpose : uint32_t
    {
        NONE = 0,
        ROUND_START = 1,
        ROUND_GENERAL = 2,
        ROUND_NEAR_END = 4, ///time low. Dynamically calculate which song to play based on time left
        ROUND_END = 8,
        MAIN_MENU = 16,
        VICTORY = 32,
        DEFEAT = 64,
        LOW_HP = 128,
        DRAMATIC = 256,
        ROUND_SPANNING  = 512 ///maybe instead of this, chop life support up into 2 clips?

        /*METEOR = 1,
        INDOORS = 2,
        GENERAL = 4,
        BADTHING = 8,
        GOODTHING = 16,
        LOWAIR = 32,
        GAMEOVER = 64,
        RETRY = 128,
        GAMESTART = 256,
        MAINMENU = 512*/
    };

    /*static std::vector<std::string> file_names =
    {
        "Sam_Berrow - THE EMPLOYMENT TAPES (PART II) - 01 Castlecool.flac",
        "Sam_Berrow - THE EMPLOYMENT TAPES (PART II) - 11 Strutters.flac",
        "Sam_Berrow - THE EMPLOYMENT TAPES (PART II) - 06 Search for Legitimacy.flac", ///need to adjust start
        "Sam_Berrow - THE EMPLOYMENT TAPES (PART II) - 07 Run!.flac",
        "Sam_Berrow - THE EMPLOYMENT TAPES (PART II) - 12 Life Support.flac",
        "Sam_Berrow - HEART AND SOUL -EP- - 02 Maniacle Monacle.flac",
        "Sam_Berrow - THE EMPLOYMENT TAPES (PART I) - 06 Indilgent.flac"
    };*/

    ///Maybe I should only have music at the start and end of rounds? And when stuff happens?
    ///need to get search for legitimacy but without the continuation
    static std::vector<std::string> file_names
    {
        "Sam_Berrow - THE EMPLOYMENT TAPES (PART I) - 06 Indilgent.flac", ///start, general
        "Sam_Berrow - THE EMPLOYMENT TAPES (PART II) - 05 Brain Journey.flac", ///general. Also for dramatic things
        "Sam_Berrow - THE EMPLOYMENT TAPES (PART II) - 07 Run!.flac", ///near_end, low_hp, or potentially general
        "Sam_Berrow - THE EMPLOYMENT TAPES (PART II) - 11 Strutters.flac", ///general? Not sure on this one
        "Sam_Berrow - THE EMPLOYMENT TAPES (PART II) - 14 Trash (Trash.).flac", ///start really
        "Sam_Berrow - HEART AND SOUL -EP- - 02 Maniacle Monacle.flac", ///general?
        "Sam_Berrow - THE EMPLOYMENT TAPES (PART I) - 10 Fenk.flac", /// can definitely use the first 8 seconds of this
        "Sam_Berrow - THE EMPLOYMENT TAPES (PART II) - 01 Castlecool.flac", ///could use this is something dramatic happens
        "Sam_Berrow - THE EMPLOYMENT TAPES (PART II) - 12 Life Support.flac" ///only use this if I can have it span across two rounds
    };

    static std::vector<uint32_t> purpose
    {
        ROUND_START | ROUND_GENERAL,
        DRAMATIC | ROUND_GENERAL,
        LOW_HP,
        ROUND_GENERAL,
        ROUND_START,
        ROUND_START | ROUND_GENERAL,
        VICTORY,
        DRAMATIC,
        ROUND_SPANNING
    };

    /*static std::vector<uint32_t> purpose =
    {
        GENERAL | INDOORS, ///use bitflag
        GENERAL,
        GOODTHING,
        LOWAIR,
        GAMEOVER | RETRY,
        GENERAL | GAMESTART,
        METEOR | MAINMENU
    };*/

    extern int current_song;
    extern sf::Music currently_playing;

    static std::string get_current_song_name()
    {
        if(current_song < 0 || current_song >= (int)file_names.size())
            return "";

        return file_names[current_song];
    }

    static void swap_to_song_type(music_purpose new_purpose)
    {
        if(new_purpose == NONE)
        {
            currently_playing.stop();
            current_song = -1;
            return;
        }

        ///at the moment do shit
        int new_song = -1;

        for(int i=0; i<(int)file_names.size(); i++)
        {
            int song_offset = (i + current_song) % file_names.size();

            music_purpose current_purpose = (music_purpose)purpose[song_offset];

            if((current_purpose & new_purpose) > 0)
            {
                new_song = song_offset;
                break;
            }
        }

        if(new_song == -1)
            return;

        if(new_song == current_song && currently_playing.getStatus() != sf::SoundSource::Stopped)
            return;

        currently_playing.stop();

        currently_playing.openFromFile("res/" + file_names[new_song]);

        currently_playing.play();

        current_song = new_song;
    }

    static void tick()
    {
        if(currently_playing.getStatus() == sf::SoundSource::Stopped)
        {
            current_song++;

            swap_to_song_type(ROUND_GENERAL);
        }
    }
};
Exemplo n.º 25
0
	void Music::SetPitch(float32 pitch)
	{ music.setPitch(pitch); }
Exemplo n.º 26
0
	void Music::SetLooping(bool isLooping)
	{ music.setLoop(isLooping); }
Exemplo n.º 27
0
	void Music::Stop()
	{ music.stop(); }
Exemplo n.º 28
0
	void Music::Play()
	{ music.play(); }
Exemplo n.º 29
0
	void Music::Pause()
	{ music.pause(); }
Exemplo n.º 30
0
	void Music::SetPosition(float32 seconds)
	{ music.setPlayingOffset(sf::Time(sf::seconds(seconds))); }