ok, i've been trying to create a pong game but i keep having this error and i don't know how to fix it.
Here is the code
#include "Game.h"
#include "Basic.h"
Game::GameState Game::gameState = Uninitialized;
sf::RenderWindow Game::MainWindow;
void Game::Start(){
if(gameState != Uninitialized){
return;}
else {
MainWindow.create(sf::VideoMode(1024,768,32),"Pong");
gameState = Game::Playing;
};
while(!Exit()){
GameLoop();
}
MainWindow.close();
};
bool Game::Exit(){
if(gameState = Exiting){
return true;}
else{return false;};
};
void Game::GameLoop(){
sf::Event Event;
if(gameState = Playing){
while(MainWindow.pollEvent(Event)){
MainWindow.clear(sf::Color::Black);
MainWindow.display();
if((Event.type == sf::Event::Closed)||(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))){
gameState = Game::Exiting;
};
};}
};
and the game.h file
#include "Basic.h"
class Game{
public:
static void Start();
static bool Exit();
static void GameLoop();
enum GameState{Uninitialized, ShowingSplash, Paused,
ShowingMenu, Playing, Exiting };
static GameState gameState;
static sf::RenderWindow MainWindow;
};
I keep having the error '"Unhandled exception at 0x77cad062 in Pong.exe: 0xC0000005: Access violation writing location 0x00000004". while running it, can somebody please help me