Advertisement
Guest User

SFML sf::Clock issue

a guest
Dec 13th, 2013
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <SFML/Graphics.hpp>
  2. #include "globals.h"
  3. #include "ScreenGame.h"
  4.  
  5. int main()
  6. {
  7.     sf::RenderWindow window(sf::VideoMode(1280, 720), "SMASH");
  8.  
  9.     xScale = 1280.0f / window.getSize().x;
  10.     yScale = 720.0f / window.getSize().y;
  11.  
  12.     screenManager.setScreen(new ScreenGame);
  13.  
  14.     sf::Clock frameClock;
  15.  
  16.     while (window.isOpen())
  17.     {
  18.         const double delta = frameClock.restart().asMilliseconds() / 16.66666667;
  19.  
  20.         sf::Event event;
  21.         while (window.pollEvent(event))
  22.         {
  23.             if (event.type == sf::Event::Closed)
  24.             {
  25.                 window.close();
  26.             }
  27.             else
  28.             {
  29.                 screenManager.currentScreen->processEvent(window, event);
  30.             }
  31.         }
  32.  
  33.         screenManager.currentScreen->update(delta);
  34.         screenManager.currentScreen->draw(window);
  35.     }
  36.  
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement