예제 #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;
  }
예제 #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
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;
}
예제 #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();
	}
}
예제 #6
0
파일: music.cpp 프로젝트: 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;
	}
}
예제 #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;
			}
			
		}
예제 #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();
		}
	}
예제 #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;
}
예제 #11
0
파일: music.hpp 프로젝트: 20k/SwordFight
    static void tick()
    {
        if(currently_playing.getStatus() == sf::SoundSource::Stopped)
        {
            current_song++;

            swap_to_song_type(ROUND_GENERAL);
        }
    }
예제 #12
0
파일: music.cpp 프로젝트: 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();
}
예제 #13
0
파일: music.hpp 프로젝트: 20k/SwordFight
    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;
    }
예제 #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 );
		}
	}
예제 #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 );
		}
	}
예제 #16
0
파일: Music.hpp 프로젝트: Shoduler/AxLib
	void Music::SetVolume(float32 volume)
	{ music.setVolume(volume); }
		void play(float _volume=1.0f)
		{
			setVolume(_volume);
			sound.play();
		}
		void setVolume(float _volume=1.0f) {
			volume = _volume;
			int intVol = _volume*100.0f;
			sound.setVolume(intVol);
		}
		void stop() {
			sound.stop();
		}
		void setLoop(bool val) {
			sound.setLoop(val);
		}
예제 #21
0
파일: Music.hpp 프로젝트: Shoduler/AxLib
	bool Music::Load(const String& fileName)
	{ return music.openFromFile(fileName.ptr); }
예제 #22
0
파일: Music.hpp 프로젝트: Shoduler/AxLib
	float32 Music::GetDurationInSeconds()
	{ return music.getDuration().asSeconds(); }
예제 #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;
}
예제 #24
0
파일: music.hpp 프로젝트: 20k/SwordFight
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);
        }
    }
};
예제 #25
0
파일: Music.hpp 프로젝트: Shoduler/AxLib
	void Music::SetPitch(float32 pitch)
	{ music.setPitch(pitch); }
예제 #26
0
파일: Music.hpp 프로젝트: Shoduler/AxLib
	void Music::SetLooping(bool isLooping)
	{ music.setLoop(isLooping); }
예제 #27
0
파일: Music.hpp 프로젝트: Shoduler/AxLib
	void Music::Stop()
	{ music.stop(); }
예제 #28
0
파일: Music.hpp 프로젝트: Shoduler/AxLib
	void Music::Play()
	{ music.play(); }
예제 #29
0
파일: Music.hpp 프로젝트: Shoduler/AxLib
	void Music::Pause()
	{ music.pause(); }
예제 #30
0
파일: Music.hpp 프로젝트: Shoduler/AxLib
	void Music::SetPosition(float32 seconds)
	{ music.setPlayingOffset(sf::Time(sf::seconds(seconds))); }