Advertisement
Felanpro

Handling Time SFML

Apr 5th, 2019
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. #include <SFML/Graphics.hpp>
  4. #include <SFML/Window.hpp>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     sf::RenderWindow window(sf::VideoMode(800, 600), "Game In Development");
  11.  
  12.     sf::Texture character_sheet;
  13.     character_sheet.loadFromFile("hero_spritesheet.png");
  14.    
  15.     sf::Time time = sf::seconds(0);
  16.  
  17.     sf::Clock clock; //Start clock
  18.  
  19.     cout << time.asSeconds() << endl;
  20.  
  21.     sf::Event event;
  22.     while (window.isOpen())
  23.     {
  24.         while (window.pollEvent(event))
  25.         {
  26.             if (event.type == sf::Event::Closed)
  27.                 window.close();
  28.         }
  29.  
  30.         window.clear(sf::Color::White);
  31.  
  32.         time = clock.getElapsedTime();
  33.         cout << time.asSeconds() << endl;
  34.  
  35.         window.display();
  36.     }
  37.  
  38.     int pause; cin >> pause; //Pause the program
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement