Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.30 KB | None | 0 0
  1. #include <SFML/Graphics.hpp>
  2. #include <SFML/Audio.hpp>
  3. #include <string>
  4. #include <list>
  5.  
  6. int main()
  7. {
  8.     sf::Text menuPoints[4];
  9.    
  10.     menuPoints[0].SetString("Neues Spiel");
  11.     menuPoints[1].SetString("Laden");
  12.     menuPoints[2].SetString("Optionen");
  13.     menuPoints[3].SetString("Beenden");
  14.  
  15.     for(int i=0; i<4; i++)
  16.     {
  17.         menuPoints[i].SetPosition(10,i*50);
  18.     }
  19.  
  20.  
  21.     sf::RenderWindow App(sf::VideoMode(800, 600, 32), "Game");
  22.    
  23.     //sf::Music Music;
  24.     //if (!Music.OpenFromFile("Sido.wav"))
  25.         //return EXIT_FAILURE;
  26.     //Music.Play();
  27.  
  28.     sf::Font MyFont;
  29.     if (!MyFont.LoadFromFile("arial.ttf"))
  30.         return EXIT_FAILURE;
  31.  
  32.  
  33.     //Schleife startet.
  34.     while (App.IsOpened())
  35.     {
  36.         sf::Event Event;
  37.         while (App.GetEvent(Event))
  38.         {
  39.             if (Event.Type == sf::Event::Closed)
  40.                 App.Close();
  41.         }
  42.  
  43.         //Bildschirm löschen
  44.         App.Clear();
  45.  
  46.         //Zeug zeichnen
  47.         for(int i=0; i<4; i++)
  48.         {
  49.             sf::FloatRect TextRect = menuPoints[i].GetRect();
  50.             sf::Vector2f MousePosition(App.GetInput().GetMouseX(), App.GetInput().GetMouseY());
  51.             if (TextRect.Contains(MousePosition.x,MousePosition.y))
  52.             {
  53.                 menuPoints[i].SetColor(sf::Color::Red);
  54.             }
  55.             else
  56.             {
  57.                 menuPoints[i].SetColor(sf::Color::White);
  58.             }
  59.             App.Draw(menuPoints[i]);
  60.         }
  61.  
  62.         //Bildschirm anzeigen
  63.         App.Display();
  64.     }
  65.     return EXIT_SUCCESS;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement