Separate the game logic from main.cpp. Make it looks a bit more like a game engine.