//Game.h
#pragma once
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
class Game
{
public:
static void Start();
private:
static bool IsExiting();
static void GameLoop();
enum GameState {Uninitialized, ShowingSplash, Paused,
ShowingMenu, Playing, Exiting};
static GameState _gameState;
static sf::RenderWindow _mainWindow;
};
#include "Game.h"
Game::GameState Game::_gameState = Uninitialized;
sf::RenderWindow Game::_mainWindow;
void Game::Start()
{
if (_gameState != Uninitialized)
return;
_mainWindow.create(sf::VideoMode(1024, 768,32), "Pang!");
_gameState = Game::Playing;
while (!IsExiting())
{
GameLoop();
}
_mainWindow.close();
}
bool Game::IsExiting()
{
if (_gameState == Game::Exiting)
return true;
else
return false;
}
void Game::GameLoop()
{
sf::Event currentEvent;
while(_mainWindow.pollEvent(currentEvent))
{
switch (_gameState)
{
case Game::Playing:
{
_mainWindow.clear(sf::Color(255,0,0));
_mainWindow.display();
if(currentEvent.type == sf::Event::Closed)
{
_gameState = Game::Exiting;
}
break;
}
}
}
}
I have error in this line: sf::RenderWindow Game::_mainWindow;.
How I can fix it?
Sorry for my English) it is not my native English)