Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

For practicing multi platform development I implemented a simple board game that is completely abstract. That means it contains all the logic and uses interfaces for the unknown or platform specific parts. For example:

  • When crating an instance of the game, the implementation has to provide an IPlayer interface for the human player. In order to get the player's next move, the engine calls GetNextMove() and the implementation has to provide the move. I implemented this for a text based console version which is using ReadKey(). For iOS, swipe gestures are used.
  • In order to display the current board, IVisualizationService has to be implemented. For the console version, this simply uses ASCII art. The iOS version uses SpriteKit. Again, the engine calls an UpdateGameField() method.

The engine is running the while(true) loop that is common to all games, performing calculations and calling out to the interface methods if required.

Now here's the question I cannot really find an answer to: currently, the abstract game is running in a separate thread in order to allow it to run without interrupting the UI thread. Somehow I think the approach is wrong. My gut feeling tells me that everything should run on the main thread and just schedule the required callbacks. The implementation would have to trigger the engine regularly. Can you please comment on the two approaches and maybe give examples for existing engines/samples/tutorials?

share|improve this question
You really don't want things running in the UI thread, as that tends to result in a 'hung' or choppy program. Although not likely an issue here, things like physics engines are often run at faster rates than the UI, to get better results. There's a number of posts around here somewhere about divorcing UI and actual game-loop threads. –  Clockwork-Muse Oct 14 '13 at 13:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.