This repository has been archived on 2022-12-14. You can view files and clone it, but cannot push or open issues or pull requests.
WaveGGJ17/VaporWaveWars/game.cpp
2017-01-20 23:52:42 +01:00

33 lines
704 B
C++

#include "game.hpp"
Game* Game::instance = nullptr;
Game::Game() {
ASSERT(Game::instance == nullptr); //Two games created
Game::instance = this;
isRunning = true;
}
Game::~Game() {
isRunning = false;
Game::instance = nullptr;
}
Game* Game::i() {
return Game::instance;
}
// Main game loop
void Game::run() {
sf::Clock c;
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
float oldTime = c.getElapsedTime().asSeconds();
while (isRunning) {
float time = c.getElapsedTime().asSeconds();
float deltaTime = time-oldTime;
oldTime = time;
update(deltaTime, &window);
draw( &window);
}
window.close();
}