Example #1
0
void showCredits(sf::RenderWindow& app)
{
  Credits credit(app);

  //Credits loop
  while (app.IsOpened()) {

    //Process events
    sf::Event Event;

    //Window closed
    while (app.GetEvent(Event)) 
    {
      if(Event.Type == sf::Event::Closed)
        app.Close();

      //Escape key pressed
      if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))	
        app.Close();
    }

    if (credit.showCredits())
    {
      app.Clear();
      credit.update();
      app.Display();
      continue;
    }
    else
    {
      break;
    }
  }
}
void drawSplashScreen(sf::RenderWindow & renderWindow)
{	
  //renderWindow.Draw(sprite::splash);


    sf::String welcome;
    toSFString("You are a chicken. \n The french are advancing and \nwant to fry you with lasers.\n\n Space to shoot, Z to fire shotgun",
	       sf::Vector2f(200, 500),
	       &welcome,
	       sf::Color(255, 0, 0));

    renderWindow.Draw(welcome);
    renderWindow.Display();


    sf::Event event;
    bool running = true;
    while (running)
    {
	while(renderWindow.GetEvent(event))
	{
	    if(event.Type == sf::Event::KeyPressed 
	       || event.Type == sf::Event::MouseButtonPressed
	       || event.Type == sf::Event::Closed )
	    {
		return;
	    }
    
	}
    }
}
Example #3
0
void SplashScreen::Show(sf::RenderWindow & renderWindow)
{
	sf::Image image;
	if(image.LoadFromFile("images/SplashScreen.png") != true)
	{
		return;
	}

	sf::Sprite sprite(image);

	renderWindow.Draw(sprite);
	renderWindow.Display();

	sf::Event event;
	while(true)
	{
		while(renderWindow.GetEvent(event))
		{
			if (event.Type == sf::Event::KeyPressed ||
				event.Type == sf::Event::MouseButtonPressed ||
				event.Type == sf::Event::Closed)
			{
				return;
			}
		}
	}
} // End Show
Example #4
0
/// This function handles any Events/Inputs thrown to the game
/// Do any input code here
/// Arguments are window => Window to register inputs from
/// THANKS TO JA_COP FOR HELPING ME OUT WITH THIS :)
void getEvents(sf::RenderWindow& window)
{
  sf::Event event;
  while(window.GetEvent(event))
  {
    switch(event.Type)
    {
      case sf::Event::Closed:
        window.Close();
      break;

      case sf::Event::KeyPressed:
        switch(event.Key.Code)
        {
          case sf::Key::Escape:
            window.Close();
          break;			

          default:
            // TODO: A call to some global key handler here? ;esa			
          break;
        }
     break;

     default:
       // I don't know what to do here but ja_cop says this:
       // Pass to input module or GUI module (placeholder)
       // so do that i guess
       // TODO: ADD MORE INPUTS
     break;
     }
  }
}
int handleEvents(){
  sf::Event event;
  while(_window.GetEvent(event)){
    switch(event.Type)
      {
      case sf::Event::KeyPressed:
	switch(event.Key.Code){
	case sf::Key::Escape:
	  quit();
	  break;
	case sf::Key::Up:
	  walk += move_step_increment;
	  walk = std::min(walk, max_move_step);
	  break;
	case sf::Key::Down:
	  walk -= move_step_increment;
	  walk = std::max(walk, .0);
	  break;
	case sf::Key::Left:
	  rotation += rotation_step_increment;
	  rotation = std::min(rotation, max_rotation_step);
	  break;
	case sf::Key::Right:
	  rotation -= rotation_step_increment;
	  rotation = std::max(rotation, -max_rotation_step);
	  break;
	case sf::Key::Return:
	  rotation = 0;
	  walk = 0;
	  break;
	case sf::Key::Q:
	  range += 10;
	  range = std::min(range, max_range);
	  updateRangeSpriteScale();
	  break;
	case sf::Key::W:
	  range -= 10;
	  range = std::max(range, min_range);
	  updateRangeSpriteScale();
	  break;
	default:
	  break;
	}	// end of key switch
	break;
      case sf::Event::MouseButtonPressed:
	if(event.MouseButton.Button == sf::Mouse::Left){
	  mouseLeftPressed(event.MouseButton.X, event.MouseButton.Y);
	}
	break;
      default:
	break;
      }	// end of event type switch
  }	// end of while
  return 0;
}
int Splash::Run(sf::RenderWindow &win, sf::VideoMode &vMode)
{
	Event events;
	while(win.IsOpened())
	{
		while(win.GetEvent(events))
		{
			if(events.Type == Event::Closed)
				win.Close();
			if(win.GetInput().IsKeyDown(Key::Space)) return 2;
		}
		if(m_scripter.RunScript(&m_splashBgImg, &m_splashBgSp) == 2) return 2;
		win.Clear();
		win.Draw(m_splashBgSp);
		win.Display();
	}
	return -1;
}
Example #7
0
void MainMenuHandler::run(sf::RenderWindow& window) {
	ImageCache mainMenuImages;
	const sf::Image& logoImage = mainMenuImages.get(Path::findDataPath("graphics/logo.png"));

	// Entering main menu, no game should be running.
	GameHandler::instance.reset();

	// Make view that is as close to 640x480 as possible and centered.
	view = window.GetDefaultView();
	view.Zoom(std::min(view.GetRect().GetWidth() / 640, view.GetRect().GetHeight() / 480));
	view.SetCenter(view.GetHalfSize());
	window.SetView(view);

	window.SetFramerateLimit(30);

	// Position at the top of the window.
	sf::Sprite logoSprite(logoImage);
	logoSprite.SetCenter(logoImage.GetWidth() / 2, 0);
	logoSprite.SetPosition(window.GetView().GetRect().GetWidth() / 2, 1);

	// Build the main menu GUI.
	GUI::Container gui;
	gui.insert(boost::shared_ptr<GUI::Object>(new GUI::Button("New game", 200, 100, 240, 50, boost::bind(&MainMenuHandler::startGame, this))));
	gui.insert(boost::shared_ptr<GUI::Object>(new GUI::Button("Exit", 250, 170, 140, 50, boost::bind(&sf::RenderWindow::Close, boost::ref(window)))));

	menuClosed = false;
	while (window.IsOpened() && !menuClosed) {
		sf::Event e;
		if (window.GetEvent(e)) {
			if (gui.handleEvent(e, window)) {
				continue;
			}
			if (e.Type == sf::Event::Closed || (e.Type == sf::Event::KeyPressed && e.Key.Code == sf::Key::Escape)) {
				window.Close();
				continue;
			}
		} else {
			window.Clear(sf::Color(0xcc, 0x66, 0x33));
			window.Draw(logoSprite);
			gui.draw(window);
			window.Display();
		}
	}
}
Example #8
0
MainMenu::MenuResult  MainMenu::GetMenuResponse(sf::RenderWindow& window)
{
  sf::Event menuEvent;

  while(true)
  {
 
    while(window.GetEvent(menuEvent))
    {
      if(menuEvent.Type == sf::Event::MouseButtonPressed)
      {
        return HandleClick(menuEvent.MouseButton.X,menuEvent.MouseButton.Y);
      }
      if(menuEvent.Type == sf::Event::Closed)
      {
        return Exit;
      }
    }
  }
}
Example #9
0
MainMenu::MenuResult MainMenu::GetMenuResponse(sf::RenderWindow& window)
{
	sf::Event menuEvent;

	while(true)
	{
		while(window.GetEvent(menuEvent))
		{
			if(menuEvent.Type == sf::Event::MouseButtonPressed)
			{
				if(ServiceLocator::GetAudio()->IsSongPlaying())
					//ServiceLocator::GetAudio()->StopAllSounds();
				return HandleClick(menuEvent.MouseButton.X, menuEvent.MouseButton.Y);
			}
			if(menuEvent.Type == sf::Event::Closed)
			{
				return Exit;
			}
		}
	}
}
Example #10
0
void SplashScreen::Show(sf::RenderWindow& renderWindow)
{
	sf::Image image;
	sf::Color bgColor = sf::Color(40,40,40);
	
	//Replace this?
	if (image.LoadFromFile("test.png") != true)
		return;
	
	sf::Sprite sprite(image);
	cerr<<renderWindow.GetWidth()/2<<" "<< renderWindow.GetHeight()/2<<endl;
	sprite.SetCenter(184/2,184/2);
	sprite.SetPosition(renderWindow.GetWidth()/2 , renderWindow.GetHeight()/2);
	
	renderWindow.Clear(bgColor);
	renderWindow.Draw(sprite);
	renderWindow.Display();
	
	sf::Event event;
	sf::Clock clock;
	
	while(clock.GetElapsedTime()<3)
	{
		while(renderWindow.GetEvent(event))
		{
			if (   event.Type == sf::Event::KeyPressed 
				|| event.Type == sf::Event::MouseButtonPressed
				|| event.Type == sf::Event::Closed) 
			{
				renderWindow.Clear(bgColor);
				return;
			}
		}
	}
	renderWindow.Clear(bgColor);
	return;
}
void SplashScreen::Show(sf::RenderWindow& window)
{
  window.Clear(sf::Color(0,0,0));

	sf::Image image;
	if(image.LoadFromFile("assets/paint-wars.png") !=true)
	{
		return;
	}
	sf::Sprite sprite(image);
	window.Draw(sprite);
	

	sf::String inst = sf::String("Press any key or click the mouse to continue.");
	inst.SetPosition(
    Game::SCREEN_WIDTH / 2 - 300,
    Game::SCREEN_HEIGHT / 2 
  );
  window.Draw(inst);

  window.Display();

  sf::Event event;
  while(true)
  {
    while(window.GetEvent(event))
    {
      if(event.Type == sf::Event::KeyPressed ||
         event.Type == sf::Event::MouseButtonPressed ||
         event.Type == sf::Event::Closed)
      {
        return;
      }
    }
  }
}
Example #12
0
int MainMenu::Run(sf::RenderWindow & App)
{
	
	

	while(m_Running)
	{
		App.Clear();
		App.Draw(m_Background);

		while(App.GetEvent(m_Event))
		{
			if(m_Event.Type == sf::Event::Closed)
			{
				m_Running = false;
				return (-1);
			}
			
			if(m_Event.Type == sf::Event::MouseButtonPressed && m_SinglePlayerRect.Contains(m_Event.MouseButton.X, m_Event.MouseButton.Y) )
			{
				// GO TO GAME
				return 4;
			}

			if(m_Event.Type == sf::Event::MouseButtonPressed && m_MultiPlayerRect.Contains(m_Event.MouseButton.X, m_Event.MouseButton.Y) )
			{
				// GO TO JOINLOBBY
				return 3;
			}

			if(m_Event.Type == sf::Event::MouseButtonPressed && m_OptionsRect.Contains(m_Event.MouseButton.X, m_Event.MouseButton.Y) )
			{
				// GO TO OPTIONS
				return 2;
			}

			if(m_Event.Type == sf::Event::MouseButtonPressed && m_ExitGameRect.Contains(m_Event.MouseButton.X, m_Event.MouseButton.Y) )
			{
				// EXIT GAME
				m_Running = false;
				return (-1);
			}
		}

		ShowMainMenuLabels(App);

std::ostringstream bufor;
sf::String tdebug;
tdebug.SetFont(sf::Font::GetDefaultFont());
tdebug.SetSize(20);
tdebug.SetColor(sf::Color(255,0,0,255));
bufor << "BufforSize= " << gResMng.Get_MapSize();
tdebug.SetText(bufor.str());
App.Draw(tdebug);			
		

		
		App.Display();
		sf::Sleep(0.01f);
	} // end of while(Running)
	


	return (-1);
}
Example #13
0
vector<Start_Items*> Start_Items::SetHair(sf::RenderWindow& App, sf::Sprite* menu)
{
	vector<Start_Items*> parts;
	int ids=0;
	if (initalizeItems(ids,parts,menu) == 1) NULL;
	else EXIT_FAILURE;
	
	//cout << parts[0]->name << endl;
	
	sf::Image img_spr;
	img_spr.LoadFromFile("sprites/fig2t.png");
	sf::Sprite spr(img_spr);
	spr.SetPosition(200,210);
	spr.Scale(1.5,1.5);
	
	sf::Image i;
	i.LoadFromFile("items/hair/next_button.jpg");
	sf::Sprite next(i);
	next.SetPosition(691,491);
	
	vector<Start_Items*> eq2;
	vector<Start_Items*> all;
	sf::String hair_str;
	
	hair_str.SetPosition(100,500);
	
	while (App.IsOpened())
	{
		App.Clear();
		sf::Event Event;
		while (App.GetEvent(Event))
		{
			if (Event.Type == sf::Event::Closed)
				App.Close();
			if (Event.Type == sf::Event::MouseButtonPressed)
			{
				if (eq2.size() >=1 && !((Event.MouseButton.X >= 691 && Event.MouseButton.X <= 755) && 
				(Event.MouseButton.Y >= 491 && Event.MouseButton.Y <=555))) eq2.clear();
				for (int x=0; x<parts.size(); x++)
				{
					if ((Event.MouseButton.X >= parts[x]->hair.GetPosition().x && Event.MouseButton.X <= parts[x]->hair.GetPosition().x+26*(parts[x]->hair.GetScale().x)) && 
					(Event.MouseButton.Y >= parts[x]->hair.GetPosition().y  && Event.MouseButton.Y <= parts[x]->hair.GetPosition().y+40*(parts[x]->hair.GetScale().y)))
					eq2.push_back(parts[x]);
				}
				if ((Event.MouseButton.X >= 691 && Event.MouseButton.X <= 755) && (Event.MouseButton.Y >= 491 && Event.MouseButton.Y <=555)) 
				{
					ids+=1;
					all.push_back(eq2[0]);
					if (initalizeItems(ids,parts,menu) == 2) return all;
				}
				
				
			}
		}
		//cout << ids << endl;
		App.Draw(*(menu));
		
		spr.SetSubRect(sf::IntRect(0,0,32,48));
		App.Draw(spr);
		if (ids>0)
		{
			for (int x=0; x<all.size(); x++)
			{
				all[x]->hair.Scale(1,1);
				all[x]->hair.SetSubRect(sf::IntRect(0,0,32,48));
				all[x]->hair.SetPosition(spr.GetPosition().x, spr.GetPosition().y);
				App.Draw(all[x]->hair);
			}
		}
		for (int x=0; x<eq2.size(); x++) 
		{
			eq2[x]->hair.Scale(1,1);
			eq2[x]->hair.SetSubRect(sf::IntRect(0,0,32,48));
			eq2[x]->hair.SetPosition(spr.GetPosition().x, spr.GetPosition().y);
			hair_str.SetText("You have selected: "+eq2[x]->name);
			App.Draw(eq2[x]->hair);
			App.Draw(hair_str);
		}
		for (int x=0; x<parts.size(); x++)
		{
			int wid=400+(50*(x+1));
			int hei=200;
			if (wid>=601) 
			{
				hei=280;
				wid=400+(50*(x-3));
			}
			parts[x]->hair.SetSubRect(sf::IntRect(0,0,32,47));
			if (parts[x]->hair.GetScale().x != 1.5) parts[x]->hair.Scale(1.5,1.5);
			parts[x]->hair.SetPosition(wid,hei);
			App.Draw(parts[x]->hair);
		}
		App.Draw(next);
		App.Display();
	}
}
Example #14
0
int GameScreen::update (sf::RenderWindow &app)
{
	int nextScreen = myID;
	float elapsedTime = app.GetFrameTime();

	sf::Event event;
	while (app.GetEvent(event)) // Boucle des évènements en attente
	{
		if (event.Type == sf::Event::Closed)
		{
			return EXIT;
		}
		else if(m_iHandler->testEvent(event, "Quit"))
		{
			return EXIT;
		}
		else if (event.Type == sf::Event::MouseMoved)
		{
			sf::Vector2f mouseCoords = app.ConvertCoords(event.MouseMove.X, event.MouseMove.Y, &ConfigOptions::getView());
			m_cursor.moveOnSquare(BoardAlignedSprite::toSquares(mouseCoords), false);
		}
		else if(m_iHandler->testEvent(event, "Up"))
		{
			sf::Vector2i s = BoardAlignedSprite::toSquares(m_cursor.GetPosition()) + sf::Vector2i(0, -1);
			if(isValid(s))
				m_cursor.moveOnSquare(s, false);
		}
		else if(m_iHandler->testEvent(event, "Left"))
		{
			sf::Vector2i s = BoardAlignedSprite::toSquares(m_cursor.GetPosition()) + sf::Vector2i(-1, 0);
			if(isValid(s))
				m_cursor.moveOnSquare(s, false);
		}
		else if(m_iHandler->testEvent(event, "Down"))
		{
			sf::Vector2i s = BoardAlignedSprite::toSquares(m_cursor.GetPosition()) + sf::Vector2i(0, 1);
			if(isValid(s))
				m_cursor.moveOnSquare(s, false);
		}
		else if(m_iHandler->testEvent(event, "Right"))
		{
			sf::Vector2i s = BoardAlignedSprite::toSquares(m_cursor.GetPosition()) + sf::Vector2i(1, 0);
			if(isValid(s))
				m_cursor.moveOnSquare(s, false);
		}
		else if(playerHasHand())
		{
			if(m_iHandler->testEvent(event, "Save"))
			{
				m_game.saveToFile(BACKUP_FILE);
			}
			else if(m_iHandler->testEvent(event, "Load"))
			{
				m_game.loadFromFile(BACKUP_FILE);
				refreshAll();
			}
			else if (m_iHandler->testEvent(event, "LClick"))
			{
				sf::Vector2f mouseCoords = app.ConvertCoords(event.MouseButton.X, event.MouseButton.Y, &ConfigOptions::getView());
				sf::Vector2i s = BoardAlignedSprite::toSquares(mouseCoords);
				if(isValid(s))
					clickOn(s);
				else if(!m_game.hasStarted())
				{
					PieceType type = m_placementUI.click(mouseCoords);
					if(type == NB_PIECES) //end of turn
						tryAndEndTurn();
					else
						m_selectedType = type;
				}
			}
			if (m_iHandler->testEvent(event, "Choose"))
			{
				sf::Vector2i s = BoardAlignedSprite::toSquares(m_cursor.GetPosition());
				if(isValid(s))
					clickOn(s);
			}
			else if (m_iHandler->testEvent(event, "RClick"))
			{
				sf::Vector2f mouseCoords = app.ConvertCoords(event.MouseButton.X, event.MouseButton.Y, &ConfigOptions::getView());
				sf::Vector2i s = BoardAlignedSprite::toSquares(mouseCoords);
				if(!m_game.hasStarted())
					remove(s);
			}
			else if (m_iHandler->testEvent(event, "EndTurn"))
			{
				tryAndEndTurn();
			}
			else if (event.Type == sf::Event::MouseWheelMoved)
			{
				if(event.MouseWheel.Delta > 0)
				{
					m_selectedType = m_placementUI.goUp();
				}
				else
				{
					m_selectedType = m_placementUI.goDown();
				}
			}
			else if (m_iHandler->testEvent(event, "Rabbit"))
			{
				selectPieceType(RABBIT);
			}
			else if (m_iHandler->testEvent(event, "Cat"))
			{
				selectPieceType(CAT);
			}
			else if (m_iHandler->testEvent(event, "Dog"))
			{
				selectPieceType(DOG);
			}
			else if (m_iHandler->testEvent(event, "Horse"))
			{
				selectPieceType(HORSE);
			}
			else if (m_iHandler->testEvent(event, "Camel"))
			{
				selectPieceType(CAMEL);
			}
			else if (m_iHandler->testEvent(event, "Elephant"))
			{
				selectPieceType(ELEPHANT);
			}
		} //end of if(playerHasHand)
		else if(isOver() && m_victorySign.GetColor().a == 255 && (m_iHandler->testEvent(event, "EndTurn") || m_iHandler->testEvent(event, "Choose") || m_iHandler->testEvent(event, "LClick")))
		{
			//if we do something after the match ends, remove the victory sign
			m_victorySign.SetColor(sf::Color(255,255,255,0));
		}

	} //end of event loop

	m_turnSign.update(elapsedTime);
	m_cursor.update(elapsedTime);
	for(std::map<PiecePtr, PieceSprite>::iterator it = m_pieces.begin(); it != m_pieces.end(); ++it)
		it->second.update(elapsedTime);

	//removing pieces that have finished disappearing
	for (auto it = m_disappearingPieces.begin(); it != m_disappearingPieces.end(); ) //++it done below if necessary
	{
		PiecePtr p = *it;
		if (m_pieces[p].hasDisappeared())
		{
			m_pieces.erase(p);
			it = m_disappearingPieces.erase(it); //gives it the value of the next element, thus no need to increase it again
		}
		else
			++it;
	}

	if(isOver()) //manages the appearance of the victory sign
	{
		int alpha = m_victorySign.GetColor().a;
		if(alpha > 0 && alpha < 255) //0 means it's disappeared already
		{
			alpha += (int) (elapsedTime * VICT_APP_SPD * 255);
			if(alpha > 255)
				alpha = 255;
			m_victorySign.SetColor(sf::Color(255,255,255,alpha));
		}
	}

	return nextScreen;
}
/**
 * Méthode principale de l'écran
 *
 * @Param sf::RenderWindow &fenetre
 * @Param Personnage &perso1
 * @Param Personnage &perso2
 * @Param Affichage &affichage
 * @Param Carte &carteJeu
 * @Son &son
 *
 * @Return int
 */
int EcranMenuMulti::run(sf::RenderWindow &fenetre, Personnage &perso1, Personnage &perso2, Affichage &affichage, Carte &carteJeu, Son &son)
{
	sf::Event monEvent;
	bool running = true;
	int i = 0;
	int j = 0;
	int k = 0;
	int l = 0;

    //Chargement de l'image de fond du menu multijoueur
    if (!ImageMulti.LoadFromFile("tilesets/MenuMulti.png"))
		std::cout << "Erreur chargement image du menu multi" << std::endl;

    //Chargement du tile pour le choix des personnages
    if (!ImagePerso.LoadFromFile("tilesets/Tile_perso.jpg"))
		std::cout << "Erreur chargement image du menu multi (tile perso)" << std::endl;

    //Chargement du tile pour le choix de la map
    if (!ImageMap.LoadFromFile("tilesets/Tile_Map.png"))
		std::cout << "Erreur chargement image du menu multi (tile map)" << std::endl;

    //Chargement de l'image flèche droite
    if (!ImageFlecheDroite.LoadFromFile("tilesets/FlecheDroite.png"))
		std::cout << "Erreur chargement image du menu multi (fleche droite) '" << std::endl;

    //Chargement de l'image flèche droite
    if (!ImageFlecheGauche.LoadFromFile("tilesets/FlecheGauche.png"))
		std::cout << "Erreur chargement image du menu multi (fleche gauche)" << std::endl;

    //Chargement de l'image pour le nombre de manches gagnantes
    if (!ImageNombreManches.LoadFromFile("tilesets/Tile_NombreManches.png"))
		std::cout << "Erreur chargement image du menu multi (tile nombre de manches)" << std::endl;


    //Chargement des images dans les sprites
    SpriteMulti.SetImage(ImageMulti);
    SpriteFlecheDroite1.SetImage(ImageFlecheDroite);
    SpriteFlecheDroite2.SetImage(ImageFlecheDroite);
    SpriteFlecheDroite3.SetImage(ImageFlecheDroite);
    SpriteFlecheDroite4.SetImage(ImageFlecheDroite);

    //Position des différents sprites
    SpriteFlecheDroite1.SetPosition(230, 450);
    SpriteFlecheDroite2.SetPosition(230, 620);
    SpriteFlecheDroite3.SetPosition(630, 390);
    SpriteFlecheDroite4.SetPosition(590, 587);

    SpriteFlecheGauche1.SetImage(ImageFlecheGauche);
    SpriteFlecheGauche2.SetImage(ImageFlecheGauche);
    SpriteFlecheGauche3.SetImage(ImageFlecheGauche);
    SpriteFlecheGauche4.SetImage(ImageFlecheGauche);
    SpriteFlecheGauche5.SetImage(ImageFlecheGauche);
    SpriteFlecheGauche1.SetPosition(50, 450);
    SpriteFlecheGauche2.SetPosition(50, 620);
    SpriteFlecheGauche3.SetPosition(420, 390);
    SpriteFlecheGauche4.SetPosition(5, 695);
    SpriteFlecheGauche5.SetPosition(455, 587);

    SpritePerso1.SetImage(ImagePerso);
    SpritePerso1.SetSubRect(sf::IntRect(0, 0, TAILLEIMAGEPERSO, TAILLEIMAGEPERSO));
    SpritePerso2.SetImage(ImagePerso);
    SpritePerso2.SetSubRect(sf::IntRect(0, 0, TAILLEIMAGEPERSO, TAILLEIMAGEPERSO));
    SpriteMap.SetImage(ImageMap);
    SpriteMap.SetSubRect(sf::IntRect(0, 0, TAILLEIMAGEMAP, TAILLEIMAGEMAP));
    SpriteNombreManches.SetImage(ImageNombreManches);
    SpriteNombreManches.SetSubRect(sf::IntRect(0, 0, TAILLEIMAGEMANCHES, TAILLEIMAGEMANCHES));
    SpritePerso1.SetPosition(115, 425);
    SpritePerso2.SetPosition(115, 595);
    SpriteMap.SetPosition(485, 350);
    SpriteNombreManches.SetPosition(520, 585);


    while(running)
	{
	    //Tant que la fenêtre contient des évènements
        while(fenetre.GetEvent(monEvent))
		{
			if (monEvent.Type == sf::Event::Closed)
				return (ECRAN_QUITTER); // On quitte le jeu

            if((monEvent.Type == sf::Event::MouseButtonPressed) && (monEvent.MouseButton.Button == sf::Mouse::Left))
            {
                //Cas ou on clique sur la fleche précédant
                if(monEvent.MouseButton.X > SpriteFlecheGauche4.GetPosition().x && monEvent.MouseButton.X < SpriteFlecheGauche4.GetPosition().x + TAILLEFLECHE)
                {
                    if(monEvent.MouseButton.Y > SpriteFlecheGauche4.GetPosition().y && monEvent.MouseButton.Y < SpriteFlecheGauche4.GetPosition().y + TAILLEFLECHE)
                    {
                        //On affiche le Menu Principal
                        return (ECRAN_MENU_PRINCIPAL);
                    }
                }
                if(monEvent.MouseButton.X > SpriteFlecheGauche1.GetPosition().x && monEvent.MouseButton.X < SpriteFlecheGauche1.GetPosition().x + TAILLEFLECHE)
                {
                    //Cas ou on clique sur la fleche précédant pour le choix du Perso 1
                    if(monEvent.MouseButton.Y > SpriteFlecheGauche1.GetPosition().y && monEvent.MouseButton.Y < SpriteFlecheGauche1.GetPosition().y + TAILLEFLECHE)
                    {
                        i = i - TAILLEIMAGEPERSO;
                        if(i < 0)
                        {
                            i = TAILLETILEPERSO - TAILLEIMAGEPERSO;
                        }

                        SpritePerso1.SetSubRect(sf::IntRect(i, 0, i + TAILLEIMAGEPERSO, TAILLEIMAGEPERSO));
                    }
                    //Cas ou on clique sur la fleche précédant pour le choix du Perso 2
                    if(monEvent.MouseButton.Y > SpriteFlecheGauche2.GetPosition().y && monEvent.MouseButton.Y < SpriteFlecheGauche2.GetPosition().y + TAILLEFLECHE)
                    {
                        j = j - TAILLEIMAGEPERSO;
                        if(j < 0)
                        {
                            j = TAILLETILEPERSO - TAILLEIMAGEPERSO;
                        }
                        SpritePerso2.SetSubRect(sf::IntRect(j, 0, j + TAILLEIMAGEPERSO, TAILLEIMAGEPERSO));
                    }
                }

                if(monEvent.MouseButton.X > SpriteFlecheDroite1.GetPosition().x && monEvent.MouseButton.X < SpriteFlecheDroite1.GetPosition().x + TAILLEFLECHE)
                {
                    //Cas ou on clique sur la fleche suivant pour le choix du Perso 1
                    if(monEvent.MouseButton.Y > SpriteFlecheDroite1.GetPosition().y && monEvent.MouseButton.Y < SpriteFlecheDroite1.GetPosition().y + TAILLEFLECHE)
                    {
                        i = i + TAILLEIMAGEPERSO;
                        if(i >= TAILLETILEPERSO)
                        {
                            i = 0;
                        }
                        SpritePerso1.SetSubRect(sf::IntRect(i, 0, i + TAILLEIMAGEPERSO, TAILLEIMAGEPERSO));
                    }
                    //Cas ou on clique sur la fleche suivant pour le choix du Perso 2
                    if(monEvent.MouseButton.Y > SpriteFlecheDroite2.GetPosition().y && monEvent.MouseButton.Y < SpriteFlecheDroite2.GetPosition().y + TAILLEFLECHE)
                    {
                        j = j + TAILLEIMAGEPERSO;
                        if(j >= TAILLETILEPERSO)
                        {
                            j = 0;
                        }
                        SpritePerso2.SetSubRect(sf::IntRect(j, 0, j + TAILLEIMAGEPERSO, TAILLEIMAGEPERSO));
                    }
                }

                if(monEvent.MouseButton.Y > SpriteFlecheDroite3.GetPosition().y && monEvent.MouseButton.Y < SpriteFlecheDroite3.GetPosition().y + TAILLEFLECHE)
                {
                    //Cas ou on clique sur la fleche précédant pour le choix de la map
                    if(monEvent.MouseButton.X > SpriteFlecheGauche3.GetPosition().x && monEvent.MouseButton.X < SpriteFlecheGauche3.GetPosition().x + TAILLEFLECHE)
                    {
                        k = k - TAILLEIMAGEMAP;
                        if(k < 0)
                        {
                            k = TAILLETILEMAP - TAILLEIMAGEMAP;
                        }
                        SpriteMap.SetSubRect(sf::IntRect(k, 0, k + TAILLEIMAGEMAP, TAILLEIMAGEMAP));
                    }
                    //Cas ou on clique sur la fleche suivant pour le choix de la map
                    if(monEvent.MouseButton.X > SpriteFlecheDroite3.GetPosition().x && monEvent.MouseButton.X < SpriteFlecheDroite3.GetPosition().x + TAILLEFLECHE)
                    {
                        k = k + TAILLEIMAGEMAP;
                        if(k >= TAILLETILEMAP)
                        {
                            k = 0;
                        }
                        SpriteMap.SetSubRect(sf::IntRect(k, 0, k + TAILLEIMAGEMAP, TAILLEIMAGEMAP));
                    }
                }


                if(monEvent.MouseButton.Y > SpriteFlecheDroite4.GetPosition().y && monEvent.MouseButton.Y < SpriteFlecheDroite4.GetPosition().y + TAILLEFLECHE)
                {
                    //Cas ou on clique sur la fleche précédant pour le choix du nombre de manches gagnantes
                    if(monEvent.MouseButton.X > SpriteFlecheGauche5.GetPosition().x && monEvent.MouseButton.X < SpriteFlecheGauche5.GetPosition().x + TAILLEFLECHE)
                    {
                        l = l - TAILLEIMAGEMANCHES;
                        if(l < 0)
                        {
                            l = TAILLETILEMANCHES - TAILLEIMAGEMANCHES;
                        }
                        SpriteNombreManches.SetSubRect(sf::IntRect(l, 0, l + TAILLEIMAGEMANCHES, TAILLEIMAGEMANCHES));
                    }

                    //Cas ou on clique sur la fleche suivant pour le choix du nombre de manches gagnantes
                    if(monEvent.MouseButton.X > SpriteFlecheDroite4.GetPosition().x && monEvent.MouseButton.X < SpriteFlecheDroite4.GetPosition().x + TAILLEFLECHE)
                    {
                        l = l + TAILLEIMAGEMANCHES;
                        if(l >= TAILLETILEMANCHES)
                        {
                            l = 0;
                        }
                        SpriteNombreManches.SetSubRect(sf::IntRect(l, 0, l + TAILLEIMAGEMANCHES, TAILLEIMAGEMANCHES));
                    }
                }

                //Cas ou on clique sur Commencer
                if(monEvent.MouseButton.X > 530 && monEvent.MouseButton.X < 710)
                {
                    if(monEvent.MouseButton.Y > 660 && monEvent.MouseButton.Y < 710)
                        {
                            //Switch sur i pour savoir quel perso a choisi le joueur 1
                            switch(i)
                            {
                                case 0*TAILLEIMAGEPERSO:
                                joueur1 = "zelda";
                                break;

                                case 1*TAILLEIMAGEPERSO:
                                joueur1 = "mario";
                                break;

                            }

                            //Switch sur j pour savoir quel perso a choisi le joueur 2
                            switch(j)
                            {
                                case 0*TAILLEIMAGEPERSO:
                                joueur2 = "zelda";
                                break;

                                case 1*TAILLEIMAGEPERSO:
                                joueur2 = "mario";
                                break;

                            }

                            //Switch sur k pour savoir quel map ont choisi les joueurs
                            switch(k)
                            {
                                case 0*TAILLEIMAGEMAP:
                                map = "zelda";
                                break;

                                case 1*TAILLEIMAGEMAP:
                                map = "mario";
                                break;

                            }

                            //On initialise le nombre de parties gagnantes
							perso1.setNombreDeManchesGagnantes((int)(l / TAILLEIMAGEMANCHES) + 1);
							perso2.setNombreDeManchesGagnantes((int)(l / TAILLEIMAGEMANCHES) + 1);

							perso1.setThemePersonnage(joueur1);
                            perso2.setThemePersonnage(joueur2);
                            affichage.setThemeCarte(map);
                            return (ECRAN_JEU); // On rentre dans l'écran du jeu
                        }
                }
            }
		}

		fenetre.Clear();
		fenetre.Draw(SpriteMulti);

		fenetre.Draw(SpriteFlecheDroite1);
		fenetre.Draw(SpriteFlecheDroite2);
		fenetre.Draw(SpriteFlecheDroite3);
		fenetre.Draw(SpriteFlecheDroite4);
		fenetre.Draw(SpriteFlecheGauche1);
		fenetre.Draw(SpriteFlecheGauche2);
		fenetre.Draw(SpriteFlecheGauche3);
		fenetre.Draw(SpriteFlecheGauche4);
		fenetre.Draw(SpriteFlecheGauche5);

		fenetre.Draw(SpritePerso1);
		fenetre.Draw(SpritePerso2);
		fenetre.Draw(SpriteMap);
		fenetre.Draw(SpriteNombreManches);
		fenetre.Display();
	}
	return (ECRAN_QUITTER);
}
Example #16
0
int Screen_Select::Run (sf::RenderWindow &App, Model* _model, Controleur* _controleur)
{
    sf::Event Event;
    bool Running = true;
    sf::Image Image;
    sf::Sprite Sprite;
    int alpha = 0;
    sf::Font Font;
	sf::String Menu0;
    sf::String Menu1;
    sf::String Menu2;
    sf::String Menu3;
    sf::String Menu4;
    int menu = 2;
	std::string ip = "";
	
	sf::SoundBuffer Buffer;
	if (!Buffer.LoadFromFile("../../Images/theme.wav"))
	{
		std::cout << "Musique pas trouvée" << std::endl;
	}
	
	sf::Sound Sound;
	Sound.SetBuffer(Buffer); // Buffer est un sfSoundBuffer
	
    if (!Image.LoadFromFile("../../Images/bf2.jpg"))
    {
        std::cerr << "Error loading bf2.jpg" << std::endl;
        return (-1);
    }
	
	Sprite.SetScale((App.GetView().GetRect().GetWidth() / 500), (App.GetView().GetRect().GetHeight() / 375));
    Sprite.SetImage(Image);
	Sprite.SetPosition(-1,-1);
	
	if (!Font.LoadFromFile("../../Images/GUNPLA3D.ttf"))
    {
        std::cerr << "Error loading font" << std::endl;
    }
	
    Menu0.SetFont(Font);
    Menu0.SetSize(25);
    Menu0.SetText("Pour jouer en Client, tapez l'ip en remplacant les . de l'adresse par des ;");
    Menu0.SetX(30);
    Menu0.SetY(App.GetView().GetRect().GetHeight() / 2 - 120);
    Menu1.SetFont(Font);
    Menu1.SetSize(25);
    Menu1.SetText("Client");
    Menu1.SetX(App.GetView().GetRect().GetWidth() / 2 - 30);
    Menu1.SetY(App.GetView().GetRect().GetHeight() / 2 - 42);
    Menu2.SetFont(Font);
    Menu2.SetSize(25);
    Menu2.SetText("Serveur");
    Menu2.SetX(App.GetView().GetRect().GetWidth() / 2 - 30);
    Menu2.SetY(App.GetView().GetRect().GetHeight() / 2);
    Menu3.SetFont(Font);
    Menu3.SetSize(25);
    Menu3.SetText("Retour");
    Menu3.SetX(App.GetView().GetRect().GetWidth() / 2 - 30);
    Menu3.SetY(App.GetView().GetRect().GetHeight() / 2 + 100);
	Menu4.SetFont(Font);
    Menu4.SetSize(25);
    Menu4.SetText(ip);
    Menu4.SetX(App.GetView().GetRect().GetWidth() / 2 - 30);
    Menu4.SetY(App.GetView().GetRect().GetHeight() / 2 + 50);
	
	App.Clear();
	
    if (playing)
    {
        alpha = alpha_max;
    }
	
	Sound.Play();
	Sound.SetLoop(true);
	
    while (Running)
    {
		
        //Verifying events
        while (App.GetEvent(Event))
        {
            // Window closed
            if (Event.Type == sf::Event::Closed)
            {
                return (-1);
            }
            //Key pressed
            if (Event.Type == sf::Event::KeyPressed)
            {
                switch (Event.Key.Code)
                {
                    case sf::Key::Up:
						if(menu == 1)
							menu++;
						if(menu == 0)
							menu++;
                        break;
                    case sf::Key::Down:
						if(menu == 1)
							menu--;
						if(menu == 2)
							menu--;
                        break;
					case sf::Key::Num0 :
						ip = ip + "O";
						break;
					case sf::Key::Num1 :
						ip = ip + "1";
						break;
					case sf::Key::Num2 :
						ip = ip + "2";
						break;
					case sf::Key::Num3 :
						ip = ip + "3";
						break;
					case sf::Key::Num4 :
						ip = ip + "4";
						break;
					case sf::Key::Num5 :
						ip = ip + "5";
						break;
					case sf::Key::Num6 :
						ip = ip + "6";
						break;
					case sf::Key::Num7 :
						ip = ip + "7";
						break;
					case sf::Key::Num8 :
						ip = ip + "8";
						break;
					case sf::Key::Num9 :
						ip = ip + "9";
						break;
					case sf::Key::SemiColon :
						ip = ip + ".";
						break;
					case sf::Key::Back :
						if(ip.size() > 0)
							ip.erase(ip.end()-1);
						break;
                    case sf::Key::Return:
						Sound.Stop();
                        if (menu == 2)
                        {
							Screen_Multi2* s4 = new Screen_Multi2(ip);
							return (s4->Run(App,_model,_controleur));
                        }
						if (menu == 1)
						{
							//Serveur
							return 3;
						}
                        else
                        {
                            return 0;
                        }
                        break;
                    default :
                        break;
                }
            }
        }
        //When getting at alpha_max, we stop modifying the sprite
        if (alpha<alpha_max)
        {
            alpha++;
        }
        Sprite.SetColor(sf::Color(255, 255, 255, alpha/alpha_div));
        if (menu == 2)
        {
            Menu1.SetColor(sf::Color(255, 0, 0, 255));
            Menu2.SetColor(sf::Color(0, 0, 0, 255));
            Menu3.SetColor(sf::Color(0, 0, 0, 255));
        }
		else if (menu == 1)
        {
            Menu1.SetColor(sf::Color(0, 0, 0, 255));
            Menu2.SetColor(sf::Color(255, 0, 0, 255));
            Menu3.SetColor(sf::Color(0, 0, 0, 255));
        }
        else
        {
            Menu1.SetColor(sf::Color(0, 0, 0, 255));
            Menu2.SetColor(sf::Color(0, 0, 0, 255));
            Menu3.SetColor(sf::Color(255, 0, 0, 255));
        }
		
        //Drawing
        App.Draw(Sprite);
		Menu4.SetText(ip);
		App.Draw(Menu0);
		App.Draw(Menu3);
		App.Draw(Menu4); 
		App.Draw(Menu1);
		App.Draw(Menu2);
		
        App.Display();
    }
	
    //Never reaching this point normally, but just in case, exit the application
    return (-1);
}
Example #17
0
int JoinGameLobby::Run(sf::RenderWindow & App)
{
	m_running = true;

	if(!m_Inited)
		Init();

	while(m_running)
	{
		App.Clear();
		App.Draw(m_Background);

		while(App.GetEvent(m_Event))
		{
			if(m_Event.Type == sf::Event::Closed)
			{
				m_running = false;
				return (-1);
			}
			// BACK TO MAIN MENU
			if(m_Event.Type == sf::Event::KeyPressed && m_Event.Key.Code == sf::Key::Escape)
			{
				m_running = false;
				return 1;
			}
			// CHECK PLAYERS ON SERVER
			if(m_Event.Type == sf::Event::KeyPressed && m_Event.Key.Code == sf::Key::F1)
			{
				SendPlayersRequest();
			}
			// JOIN TO GAME
			if(m_Event.Type == sf::Event::KeyPressed && m_Event.Key.Code == sf::Key::F5)
			{
				SendNewPlayerJoin();
			}

			m_serverIPBox->HandleEvent(m_Event);

		} // end of events while loop

#pragma region debuginfo
std::ostringstream bufor;
sf::String tdebug;
tdebug.SetFont(sf::Font::GetDefaultFont());
tdebug.SetSize(20);
tdebug.SetColor(sf::Color(255,0,0,255));
bufor << "Port= " << GMGI->m_SocketUDP.GetPort() << "\nPing= " << m_ServerPing;
bufor << "\n" << "Players Count= " << m_PlayerCount;
tdebug.SetText(bufor.str());
App.Draw(tdebug);	
#pragma endregion

		// if server accept my connection. Go to OnlineGame
		if(m_StartGame)
			return 5;


		RecivePackets();

		// draw textbox for server ip
		m_serverIPBox->Show(App);

		// check ping every 5sec
		if(m_pingclock.GetElapsedTime() >= 5.f)
		{
			SendPingRequest();
			m_pingclock.Reset();
		}

		

		App.Display();
		sf::Sleep(0.01f);
	} // end of while loop

	return (-1);
}
Example #18
0
//function
bool AccessOptions::runAccess(sf::RenderWindow &Menu, World& myWorld, Player& myPlayer)
{
    //extern World myWorld;
    //creating an image and using events
    sf::Event Event;

    sf::Image image;
    if(!image.LoadFromFile("images/accessMenu2.png"))
    return false;

    //create a sprite
    sf::Sprite sprite;
    sprite.SetImage(image);

    int xoffset = 50;
    int yoffset = 25;

    sprite.SetPosition(xoffset,yoffset);

    //list of Buttons on screen
    Button newGame = Button(305,73,Position(100+xoffset,42+yoffset));
    Button saveGame = Button(193,72,Position(165+xoffset,150+yoffset));
    Button resumeGame = Button(233,74,Position(144+xoffset,269+yoffset));
    Button exitGame = Button(139,87,Position(195+xoffset,380+yoffset));

    while(Menu.IsOpened())
    {
        //loop for event handling
        if(Menu.GetEvent(Event))
        {
            if(Event.Type==sf::Event::Closed)
            Menu.Close();

            Position click = Position(Event.MouseButton.X, Event.MouseButton.Y);
            //determining what button is pressed & task to follow
            if(Event.Type==sf::Event::MouseButtonPressed && newGame.clickedOn(click))
                {
                    sf::RenderWindow App;
                    startNewGame(Menu, App);
                }
            if(Event.Type==sf::Event::MouseButtonPressed && saveGame.clickedOn(click))
                {
                    saveSector(myWorld,myPlayer);
                }
            if(Event.Type==sf::Event::MouseButtonPressed && resumeGame.clickedOn(click))
                {
                    return true;
                }
            if(Event.Type==sf::Event::MouseButtonPressed &&exitGame.clickedOn(click))
                {
                    //also closes all other windows and system
                    return false;
                }
            }
        //clear window
        //Menu.Clear();

        //draw sprite
        Menu.Draw(sprite);
        //display
        Menu.Display();
    }
    return true;
}
Example #19
0
int ScreenMenu::Run(sf::RenderWindow &App)
{
	//sf::Event Event;
	//sf::Image background;
	//background.LoadFromFile("Sprites\\backgroundMenu.png");
	//sf::Sprite backgroundSprite;
	//backgroundSprite.SetImage(background);

	//sf::String menuPlay("Commencer une nouvelle partie", myFont, 35);
	//menuPlay.SetPosition(150.f, 150.f);
	//sf::String menuCommandes("Aide", myFont, 35);
	//menuCommandes.SetPosition(360.f, 280.f);
	//sf::String menuQuit("Quitter", myFont, 35);
	//menuQuit.SetPosition(340.f, 410.f);

	//menuPlay.SetColor(sf::Color(0,255,0));
	//menuPlay.SetSize(37);

	////Draw (Initialisation

	//App.Clear();
	//App.Draw(backgroundSprite);
	//App.Draw(menuPlay);
	//App.Draw(menuCommandes);
	//App.Draw(menuQuit);
	//App.Display();

	int selected = 1;

	bool running = true;
	while(running)
	{
		while (App.GetEvent(Event))
		{
			//Clavier
			if (Event.Type == sf::Event::Closed)
			{
				return (SCREEN_EXIT);
			}
			if ((Event.Type == sf::Event::KeyPressed) && ((Event.Key.Code == sf::Key::Down) || (Event.Key.Code == sf::Key::Right)))
			{
				if(selected != 3)
					selected++;
				else
					selected = 1;
			}
			if ((Event.Type == sf::Event::KeyPressed) && ((Event.Key.Code == sf::Key::Up) || (Event.Key.Code == sf::Key::Left)))
			{
				if(selected != 1)
					selected--;
				else
					selected = 3;
			}

			//Joystick
			if((Event.Type == sf::Event::JoyMoved) && (Event.JoyMove.JoystickId == 0))
			{
				if((Event.JoyMove.Axis == sf::Joy::Axis::AxisX) || (Event.JoyMove.Axis == sf::Joy::Axis::AxisY))
				{
					if(Event.JoyMove.Position == 100)
					{
						if(selected != 3)
							selected++;
						else
							selected = 1;
					}
					if(Event.JoyMove.Position == -100)
					{
						if(selected != 1)
							selected--;
						else
							selected = 3;
					}
				}
			}

			if((Event.Type == sf::Event::JoyButtonPressed) && (Event.JoyMove.JoystickId == 0))
			{
				switch(selected)
				{
				case 1:
					return(SCREEN_SETUP);
					break;
				case 2:
					return(SCREEN_COMMAND);
					break;
				case 3:
					return(SCREEN_EXIT);
					break;
				}
			}



			if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Return))
			{
				switch(selected)
				{
				case 1:
					return(SCREEN_SETUP);
					break;
				case 2:
					return(SCREEN_COMMAND);
					break;
				case 3:
					return(SCREEN_EXIT);
					break;
				}
			}

			//Update

			switch(selected)
			{
			case 1:
				menuPlay.SetColor(sf::Color(0,255,0));
				menuCommandes.SetColor(sf::Color(255,255,255));
				menuQuit.SetColor(sf::Color(255,255,255));
				menuPlay.SetSize(37);
				menuCommandes.SetSize(35);
				menuQuit.SetSize(35);
				break;
			case 2:
				menuPlay.SetColor(sf::Color(255,255,255));
				menuCommandes.SetColor(sf::Color(255,255,0));
				menuQuit.SetColor(sf::Color(255,255,255));
				menuPlay.SetSize(35);
				menuCommandes.SetSize(37);
				menuQuit.SetSize(35);
				break;
			case 3:
				menuPlay.SetColor(sf::Color(255,255,255));
				menuCommandes.SetColor(sf::Color(255,255,255));
				menuQuit.SetColor(sf::Color(255,0,0));
				menuPlay.SetSize(35);
				menuCommandes.SetSize(35);
				menuQuit.SetSize(37);
				break;
			}


		}

		Draw(App);
		App.SetFramerateLimit(FPS);

	}

}
void ProcessAppEvents(sf::RenderWindow &App, sf::View &v, GroupManager &gm)
{
    sf::Event Event;
    while (App.GetEvent(Event))
    {
        switch (Event.Type)
        {
            case sf::Event::Closed: App.Close(); break;
            case sf::Event::KeyPressed:
            {
                switch (Event.Key.Code)
                {
                    case sf::Key::Escape: App.Close(); break;
                    case sf::Key::Right:
                    case sf::Key::Left:
                    case sf::Key::Up:
                    case sf::Key::Down:
                    {
                        const int step = 5;
                        v = App.GetView();
                        int hor = 0, ver = 0;
                        if (Event.Key.Code == sf::Key::Left)
                            hor+=step;
                        if (Event.Key.Code == sf::Key::Right)
                            hor-=step;
                        if (Event.Key.Code == sf::Key::Up)
                            ver+=step;
                        if (Event.Key.Code == sf::Key::Down)
                            ver-=step;
                        v.Move(hor, ver);
                        App.SetView(v);
                        break;
                    }
                    case sf::Key::S:
                    case sf::Key::D:
                    {
                        //if (Event.Key.Code == sf::Key::S)
                        //    wanna_step_per_second-= wanna_step_per_second/10 - 1;
                        //if (Event.Key.Code == sf::Key::D)
                        //    wanna_step_per_second+= wanna_step_per_second/10 + 1;
                        //if (wanna_step_per_second <= 0)
                        //    step_per_second = 1;
                        //if (wanna_step_per_second >= 250)
                        //    step_per_second = 250;
                        //step_time = 1.0/wanna_step_per_second;
                        break;
                    }
                    case sf::Key::W:
                    case sf::Key::E:
                    {
                        if (Event.Key.Code == sf::Key::E)
                            gm.SetStepSize(gm.GetStepSize() + 0.005);
                        if (Event.Key.Code == sf::Key::W)
                            gm.SetStepSize(gm.GetStepSize() - 0.005);
                        break;
                    }
                    case sf::Key::Z:
                    case sf::Key::X:
                    {
                        if (Event.Key.Code == sf::Key::Z)
                            v.Zoom(1.01);
                        if (Event.Key.Code == sf::Key::X)
                            v.Zoom(1.0/1.01);
                        break;
                    }
                    case sf::Key::A:
                    {
                        step_mode = (STEP_MODE) ((int)SM_HARD_STEPS_CNT + (int)SM_FREE_STEPS_CNT - step_mode);
                        break;
                    }
                    default: break;
                }
                break;
            }
            case sf::Event::Resized:
            {
                int h = Event.Size.Height;
                int w = Event.Size.Width;
                v.SetHalfSize(w/2, h/2);
                break;
            }
            default: break;
        }
    }
}
/**
 * Méthode principale de l'écran
 *
 * @Param sf::RenderWindow &fenetre
 * @Param Personnage &perso1
 * @Param Personnage &perso2
 * @Param Affichage &affichage
 * @Param Carte &carteJeu
 * @Son &son
 *
 * @Return int
 */
int EcranMancheFinie::run(sf::RenderWindow &fenetre, Personnage &perso1, Personnage &perso2, Affichage &affichage, Carte &carteJeu, Son &son)
{
	sf::Event monEvent;
	bool running = true;

	// On joue le son de victoire
	son.playWin();

	// Boucle du menu principal
	while(running)
	{
		while(fenetre.GetEvent(monEvent))
		{
		    if (monEvent.Type == sf::Event::Closed)
		    {
		        //On stoppe la musique
                son.stopMusic();
				return (ECRAN_MENU_PRINCIPAL); // On quitte le jeu
		    }

			if ((monEvent.Type == sf::Event::KeyPressed) && (monEvent.Key.Code == sf::Key::Return))
            {
				// On relance le jeu à nouveau
				return (ECRAN_JEU);
			}
			if ((monEvent.Type == sf::Event::KeyPressed) && (monEvent.Key.Code == sf::Key::Escape))
            {
                son.stopMusic();
				// On relance le jeu à nouveau
				return (ECRAN_MENU_PRINCIPAL);
			}

		}
		// On affiche le contenu de l'écran
        fenetre.Clear();
        affichage.displayFond(fenetre);
        affichage.displayMap(fenetre);

		// On affiches les sprites de fin de manche
		if(perso1.isVivant() && !perso2.isVivant())
		{
			affichage.displayFinManche(fenetre, "1", 100, 250);
		}
		else if(perso2.isVivant() && !perso1.isVivant())
		{
			affichage.displayFinManche(fenetre, "2", 100, 250);
		}
		else if(!perso1.isVivant() && !perso2.isVivant())
		{
		    affichage.displayFinMancheEgal(fenetre, 100, 250);
        }

		affichage.displayPersoFini(&perso1, fenetre);
		affichage.displayPersoFini(&perso2, fenetre);

		// On affiche les scores
		affichage.displayScore(fenetre,perso1,90);
        affichage.displayScore(fenetre,perso2,400);
        // On affiche le contenu de la fenetre
		affichage.displayAvatar(fenetre);
		fenetre.Display();
	}
	// Normalement on atteint jamais cet endroit, si jamais ça arrive on quitte le jeu.
	return (ECRAN_QUITTER);
}