Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For our school project we'd like to develop a game using the MVC pattern. We're all moderate new java programmers and absolutely new in game development.

With our current view (containing only menu) using swing we have no issues. But we'd like to make the menu navigation within the game loop. And there's the issue: The game loop prevents the controller to continue. The solution sounds easy, but the implementation lacks some of my/our knowledge, additional thread. I think using a separate thread for view makes handling all stuff threadsafe difficult.

Our game loop is based on nifty, which is using slick2d and this is based on lwjgl (and so on). Reverting to swing does not solve our issue, because once we're in the real game loop, the situation would be the same (so far I understand).

I hope it is understandable without posting huge amount of code. Two questions comes to mind: How should threading be done, when my current try is having a (looping) view instance in its own thread? (Reading a bit here on gamedev seems to call our architecture in question) Is MVC the right choice if we're using slick as framework?

share|improve this question


I suggest you use just one thread for now. In my opinion, using multiple threads for rendering and game interactions will only complicate your code and introduce synchronization overhead, so the only time I would do that is if I MUST improve performance by using multiple threads for multiple CPUs (in which case you should profile first before optimizing). However, you should still keep your code modular which is where MVC comes in.


The main idea that you should take from MVC is to separate rendering logic and game logic. The Model maintains state information about the game and View simply reads that state from the Model and render it. Controller should be hooked up to handle input and modify the Model as well as initiating the update on the View.

A good example of a single thread MVC-ish game is

It's based on LibGDX (cross platform Java game library).

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.