Hi, I just started at a pang tutorial. It's made from SFML 1.6 but I have found and corrected what's wrong and updated it to the newest version. But I seem to have a error, whenever I load the window it quits. I can't seem to find out whats wrong. Heres my code
Game.h:
I have added the headers and everything else
public:
static void Start();
private:
static bool IsExisting();
static void GameLoop();
enum GameState { Unititialized, ShowingSplash, Paused,
ShowingMenu, Playing, Exiting };
static GameState _gameState;
static sf::RenderWindow _mainWindow;
Game.cpp
#include "stdafx.h"
#include "Game.h"
void Game::Start(void)
{
if (_gameState != Unititialized)
return;
_mainWindow.create(sf::VideoMode(1024, 768, 32), "Pang!");
_gameState = Game::Playing;
while (!IsExisting())
{
GameLoop();
}
_mainWindow.close();
}
bool Game::IsExisting()
{
if (_gameState == Game::Exiting)
return false;
else
return true;
}
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;
}
}
}
}
Game::GameState Game::_gameState = Unititialized;
sf::RenderWindow Game::_mainWindow;
stadfax.h:
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/Audio.hpp>
#include <map>
#include <iostream>
#include <cassert>
Thanks in advance