Advertisement
Guest User

SFML Demo - Working

a guest
Feb 18th, 2012
67
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.     // Create the render window
  14.     RenderWindow win(VideoMode(800, 600), "ProjectX - development version");
  15.     Event evt;
  16.  
  17.     // Create and load textures and sprites
  18.     Texture tex;
  19.     if(!tex.LoadFromFile("data/sprites/UFO/single.png"))
  20.         return EXIT_FAILURE;
  21.  
  22.     Sprite sprite(tex);
  23.  
  24.     /* MAIN LOOP */
  25.     while(win.IsOpen())
  26.     {
  27.         // Clear back buffer
  28.         win.Clear();
  29.  
  30.         // Process events
  31.         while(win.PollEvent(evt))
  32.         {
  33.             // Exit if the user presses ESC or clicks on window close button
  34.             if(evt.Type == Event::Closed || (evt.Type == Event::KeyPressed and evt.Key.Code == Keyboard::Escape))
  35.                 win.Close();
  36.         }
  37.  
  38.         win.Draw(sprite);
  39.  
  40.         // Display changes
  41.         win.Display();
  42.     }
  43.  
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement