Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

I'd like to make a 2D game in Java using the Model-View-Controller (MVC) pattern, but I have some issues concerning the battles.

There are two groups of characters in each battle: heroes and monsters. The player controls the heroes. My game is turn-based: I'd like to select one character at a time, ask the player the action to use, its target, and finally execute the action. However I can't seem to adjust this sequence of commands with the MVC pattern.

Could anyone help me?

share|improve this question

closed as not a real question by Byte56, Anko, msell, bummzack, Nate May 1 '13 at 21:26

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Yep, someone can help you. But you'll have to make it clearer what you're asking. What have you tried? Why is it failing? – Anko Apr 30 '13 at 15:30
My problem is the turn-based battle implementation. I created a Battle object in my model. This Battle object knows the two groups. It is able to run a turn at a time as well. In my point of view, it should also be able to run the battle in its entirety : each character attacks and it goes on until the death of one of the groups. But between every attack, for the heroes, I need the commands of the player, which will be received by the GUI, and given to the controller. So, I'd like to know if it's correct or which path should i take to resolve this little problem... Thx ! – user2336243 May 1 '13 at 8:52
Edit : I've implemented what I just said. The battle object is able to manage turns : I invoke a new turn after each attack. Therefore, the entirety of the battle is managed by the view, and it doesn't seem normal to me. That's my problem and what I'd like to do. Sorry for not being clear... And thanks. – user2336243 May 1 '13 at 9:10

You can solve this by implementing the controller as a state machine with four states:

  • select character
  • select action
  • select target
  • wait for animation to finish

In each of these state different GUI elements are shown/hidden and the inputs of the user are interpreted differently.

Instead of implementing it as a state machine, you could also implement it with four individual controller classes, one for each state.

share|improve this answer
I'll look into it. Thanks – user2336243 May 1 '13 at 8:55

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