示例#1
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();
}
		void init(string path) {
			if ( !sound.openFromFile(path) ) {
				cout << "error loading music";
				return;
			}
			
		}
示例#3
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
}
示例#4
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;
}
示例#5
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;
  }
示例#6
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();
		}
	}
示例#7
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;
}
示例#8
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;
    }
示例#9
0
文件: Music.hpp 项目: Shoduler/AxLib
	bool Music::Load(const String& fileName)
	{ return music.openFromFile(fileName.ptr); }
示例#10
0
void chargerMusic(sf::Music& music, std::string filePath)
{
    if(!music.openFromFile(filePath))
        std::cerr << "Erreur durant chargement de la musique " << filePath << std::endl;
}
示例#11
0
ambiance::ambiance()
{
// INSTANCES D //

	ambDA.setVolume(0);
	ambDA.setLoop(false); 

	ambDB.setVolume(70);
	ambDB.setLoop(false); 

	ambDC.setVolume(100);
	ambDC.setLoop(false);

	ambDD.setVolume(100);
	ambDD.setLoop(false);

	ambDA.openFromFile(path+"ambDA01.ogg");
	ambDB.openFromFile(path+"ambDB01.ogg");
	ambDC.openFromFile(path+"ambDC01.ogg");
	ambDD.openFromFile(path+"ambDD01.ogg");

	// LOAD ALL FILES (AKA RONNYHAX) ////////////////////////////////////////////


	for(int i = 0; i < ARRAY_SIZE(ambAAFile); i++)
	{
		ALLambAA[i].openFromFile(path+ambAAFile[i]);
		ALLambAA[i].setVolume(0);
		ALLambAA[i].setLoop(true); 
	}

	for(int i = 0; i < ARRAY_SIZE(ambABFile); i++)
	{
		ALLambAB[i].openFromFile(path+ambABFile[i]);
		ALLambAB[i].setVolume(0);
		ALLambAB[i].setLoop(true); 
	}

	for(int i = 0; i < ARRAY_SIZE(ambBAFile); i++)
	{
		ALLambBA[i].openFromFile(path+ambBAFile[i]);
		ALLambBA[i].setVolume(0);
		ALLambBA[i].setLoop(true); 
	}

	for(int i = 0; i < ARRAY_SIZE(ambBBFile); i++)
	{
		ALLambBB[i].openFromFile(path+ambBBFile[i]);
		ALLambBB[i].setVolume(0);
		ALLambBB[i].setLoop(true); 
	}

	for(int i = 0; i < ARRAY_SIZE(ambBCFile); i++)
	{
		ALLambBC[i].openFromFile(path+ambBCFile[i]);
		ALLambBC[i].setVolume(0);
		ALLambBC[i].setLoop(true); 
	}

	for(int i = 0; i < ARRAY_SIZE(ambCAFile); i++)
	{
		ALLambCA[i].openFromFile(path+ambCAFile[i]);
		ALLambCA[i].setVolume(0);
		ALLambCA[i].setLoop(true); 
	}

	for(int i = 0; i < ARRAY_SIZE(ambCBFile); i++)
	{
		ALLambCB[i].openFromFile(path+ambCBFile[i]);
		ALLambCB[i].setVolume(0);
		ALLambCB[i].setLoop(true); 
	}

	for(int i = 0; i < ARRAY_SIZE(ambCCFile); i++)
	{
		ALLambCC[i].openFromFile(path+ambCCFile[i]);
		ALLambCC[i].setVolume(0);
		ALLambCC[i].setLoop(true); 
	}
	// RAND TIME & ARRAYLENGTH DEFINITION //
		srand (time(0));	
}
示例#12
0
int main(int argc, char** argv){

     if (argc != 7) {
    cerr << "Wrong call\n";
    return 1;
  }
  
  // [Dirtracker][PortTracker][NodoActualDir][NodoActualPort][DirFiles][Delay]
  // ./Client localhost 5555 localhost 6666 Temp 5
  string TrackerDir=argv[1];
  string TrackerPort=argv[2];
  string NodeDir=argv[3];
  string NodePort=argv[4];

  string TrackerConnect="tcp://"+TrackerDir+":"+TrackerPort; 
  string NodeListenerConnect="tcp://*:"+NodePort;
  string NodeDirSite="tcp://"+NodeDir+":"+NodePort; 

  Tpath= argv[5];
  cout<<"Path: "<<Tpath<<endl;
  int Time = atoi(argv[6]);

  zctx_t* context = zctx_new();

  void* Tracker = zsocket_new(context, ZMQ_DEALER);
  int a = zsocket_connect(Tracker, TrackerConnect.c_str());
  cout << "connecting to Tracker: "<<TrackerConnect << (a == 0 ? " OK" : "ERROR") << endl;
  cout << "Listening! Tracker" << endl;

  void* NodeListener = zsocket_new(context, ZMQ_ROUTER);
  int b = zsocket_bind(NodeListener,NodeListenerConnect.c_str());
  cout << "Listening! Nodes at : "<<NodeListenerConnect << (b == 0 ? " OK" : "ERROR") << endl; 
  

  zmq_pollitem_t items[] = {{Tracker, 0, ZMQ_POLLIN, 0},
                            {NodeListener, 0, ZMQ_POLLIN, 0}};

  DirFiles(Tpath);                          
  SplitFiles(Tpath);
  DirFiles(Tpath);                           
  RegPeer(Tracker,NodeDirSite);

  thread Poll(PollItems,Tracker,NodeListener,items,context,NodeDirSite);
  Poll.detach();
  
  for(int i=0;i<FileList.size();i++){
      cout<<"Item ["<<i<<"]: "<<FileList[i]<<endl;
     }
  int op=0;   
  while(op!=7){   
  cout<<"LL      iii lll  '     TTTTTTT                                     tt"<<endl;    
  cout<<"LL          lll '''      TTT    oooo  rr rr  rr rr    eee  nn nnn  tt"<<endl;    
  cout<<"LL      iii lll ''       TTT   oo  oo rrr  r rrr  r ee   e nnn  nn tttt"<<endl;  
  cout<<"LL      iii lll          TTT   oo  oo rr     rr     eeeee  nn   nn tt"<<endl;    
  cout<<"LLLLLLL iii lll          TTT    oooo  rr     rr      eeeee nn   nn  tttt"<<endl; 
  cout<<"::::::::::::::::::::::::::::::"<<endl;
  cout<<"::::::::     MENU    :::::::::"<<endl;
  cout<<"::::::::::::::::::::::::::::::"<<endl;
  cout<<":: 1-> Search :::"<<endl;
  cout<<":: 2-> Download :::"<<endl;
  cout<<":: 3-> Play Song (sin extensión) :::"<<endl;
  cout<<":: 4-> Pause :::"<<endl;
  cout<<":: 5-> Stop :::"<<endl;
  cout<<":: 6-> Play in memory :::"<<endl;
  cout<<":: 7-> Exit :::"<<endl;  
  
  cin>>op;

  
  switch (op){
    case 1 :
    QuerySearch(Tracker);
    break;
    
    case 2 :
    QueryListFile(Tracker);
    break;

    case 3 :
    Save.lock();
    if(Cont1!=Cont2){
      cout<<"No se puede reproducir, canción incompleta , \n ¡espera hasta que se termine de descargar!"<<endl;
      }else{
        string Song;
        cin>>Song;
        string sentence= "7z x Temp/"+Song+".7z.001";
        system(sentence.c_str());
        if(music.openFromFile("Temp/"+Song+".ogg")){
          music.stop();
          music.play();
        }
      }
    Save.unlock();
    break;
    
    case 4 :
    music.pause();
    break;
    
    case 5 :
    music.stop();
    break;


    case 6 :
    music.play();
    break;
         
  }
  
}
  DirFiles(Tpath);        
  Disconnect(Tracker,NodeDirSite);
  

  Poll.~thread();
 
  zctx_destroy(&context);
  return 0;
 
}
示例#13
0
// ----------------------------------------------------------------------------
//Called when a key is pressed
void handleKeypress(unsigned char key, //The key that was pressed
					int x, int y)
{    //The current mouse coordinates
    float xrotrad, yrotrad;
	switch (key) {

		case 'f':
		case 'F':
			if(full_screen){
				full_screen=FALSE;
				f_s_off=TRUE;
			}
			else full_screen=TRUE;
			break;

        case 'r':
		case 'R':
            reload();
            break;

		case 32://Space key
			if(menu && menu_id==0)menu_id=2; //metti menu credits
            break;

		case 'c':
		case 'C':
			if(menu && menu_id==0)menu_id=1; //metti menu comandi
            break;

		case 13: //Enter key
			if(menu_id==0){
				menu_id=5; //Inizia a Giocare (Esci dai menu!)
				newGame();
				menu=FALSE;
			}
			break;

		case 8: //Backspace key
			if(!pause){
				if(menu_id==4){
					music.stop();
					music.openFromFile("./dati/audio/Rango_Theme.ogg");
					music.play();
				}
				menu_id=0;//Torna al menu pricipale
				menu=TRUE;
			}
			break;

        case 'p':
		case 'P':
			if(menu && menu_id==0)menu_id=3; //metti menu personaggi
            break;

		case 's':
		case 'S':
			if(menu_id==5){
				if(pause) {
					music_pause.stop();
					music.play();
					pause=FALSE;
				}
				else {
					//musica
					music.pause();
					music_pause.openFromFile("./dati/audio/Lizard.ogg");
					music_pause.play();
					pause=TRUE;
				}
			}
			break;

		case 27: //Escape key
			exit(0); //Exit the program
	}
}