It's like:
main.cpp
#include "main.h"
#include "engine.h"
int main()
{
engine engine;
engine.game();
return EXIT_SUCCESS;
}
engine.cpp
engine::engine()
{
window.EnableKeyRepeat(false);
window.Create(sf::VideoMode(1024,768,32),"RPG");
}
void engine::game()
{
while(window.IsOpened())
{
while(window.GetEvent(Event))
{
if(Event.Type == sf::Event::Closed)
window.Close();//exit
}
if(GSchanged)//GameState changed
Load();//load stuff for the new GameState
Draw();//Draw everything onto the screen
HandleInput();//handle input for each gamestate
}
}
void engine::HandleInput()
{
if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::F1))
{
//...
}
}