Advertisement
TermSpar

SFML Template

Jun 30th, 2016
2,186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. //SFML Template by Ben Bollinger
  2.  
  3. #include <iostream>
  4. #include <SFML/Graphics.hpp>
  5.  
  6. int main(){
  7.     sf::RenderWindow window;
  8.    
  9.     sf::Vector2i centerWindow((sf::VideoMode::getDesktopMode().width / 2) - 445, (sf::VideoMode::getDesktopMode().height / 2) - 480);
  10.  
  11.     window.create(sf::VideoMode(900, 900), "SFML Project", sf::Style::Titlebar | sf::Style::Close);
  12.     window.setPosition(centerWindow);
  13.  
  14.     window.setKeyRepeatEnabled(true);
  15.  
  16.     //Main Loop:
  17.     while(window.isOpen()){
  18.        
  19.         sf::Event Event;
  20.  
  21.         //Event Loop:
  22.         while(window.pollEvent(Event)){
  23.             switch(Event.type){
  24.  
  25.             case sf::Event::Closed:
  26.                 window.close();
  27.             }
  28.  
  29.         }
  30.         window.clear();
  31.         window.display();
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement