I have some head pain with putting some functionality in correct class. For example I have an operation like this:

  1. player selects world space tile
  2. game detects which tile is selected
  3. game detects what objects it holds
  4. game analyzes in what state is player. If it's in moving state - when it moves player to a selected tile. If it's in attack state - when player's character attacks nearby actor.

would it be right if i put code like that in PlayStateUI class?

  • \$\begingroup\$ Your question is a bit vague. Can you try again to explain what you want to do and what the problem is? \$\endgroup\$ – MichaelHouse Feb 20 '13 at 1:31
  • \$\begingroup\$ As I said. I have game functionality that I mentioned above, but I don't know which class would be a good place for it. UI or some kind of manager? I don't know. \$\endgroup\$ – user2055675 Feb 20 '13 at 1:41
  • 2
    \$\begingroup\$ Well, that's sort of irrelevant. You should put the code where it makes the most sense to you. The game doesn't care where the code is, just the order it's called in. The organization is totally up to your personal preference. \$\endgroup\$ – MichaelHouse Feb 20 '13 at 2:29
  • 1
    \$\begingroup\$ Is PlayStateUI the name of a class you created? If so, are you just asking if that's a good name for a class? \$\endgroup\$ – Cameron Fredman Feb 20 '13 at 2:47

You could put that all in the same class. It's really up to you. Alternatively, you can separate the user interface and the game logic into separate classes. For example, it looks like number 1 on your list is related to the user interface, while numbers 2 through 4 relate to game logic. Thus, you could put #1 into the PlayStateUI class and the rest into a PlayStateManager class.

  • \$\begingroup\$ Thank You. That was the answer I wanted to hear. Now it makes sense. \$\endgroup\$ – user2055675 Feb 20 '13 at 13:15

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