Advertisement
Guest User

SFML Demo - Not working

a guest
Feb 18th, 2012
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. // Standard C++ headers
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. // SFML headers
  6. #include <SFML/Graphics.hpp>
  7. #include <SFML/System.hpp>
  8. using namespace sf;
  9.  
  10. int main()
  11. {
  12.     /* INITIALIZATION */
  13.     Event evt;
  14.  
  15.     // Create and load textures and sprites
  16.     Texture tex;
  17.     if(!tex.LoadFromFile("data/sprites/UFO/single.png"))
  18.         return EXIT_FAILURE;
  19.  
  20.     Sprite sprite(tex);
  21.  
  22.     // Create the render window
  23.     RenderWindow win(VideoMode(800, 600), "ProjectX - development version");
  24.  
  25.     /* MAIN LOOP */
  26.     while(win.IsOpen())
  27.     {
  28.         // Clear back buffer
  29.         win.Clear();
  30.  
  31.         // Process events
  32.         while(win.PollEvent(evt))
  33.         {
  34.             // Exit if the user presses ESC or clicks on window close button
  35.             if(evt.Type == Event::Closed || (evt.Type == Event::KeyPressed and evt.Key.Code == Keyboard::Escape))
  36.                 win.Close();
  37.         }
  38.  
  39.         win.Draw(sprite);
  40.  
  41.         // Display changes
  42.         win.Display();
  43.     }
  44.  
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement