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.

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?

share|improve this question

closed as not constructive by Byte56, Josh Petrie, bummzack, Trevor Powell, Tetrad Feb 20 '13 at 17:37

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Your question is a bit vague. Can you try again to explain what you want to do and what the problem is? –  Byte56 Feb 20 '13 at 1:31
    
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. –  user2055675 Feb 20 '13 at 1:41
2  
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. –  Byte56 Feb 20 '13 at 2:29
1  
Is PlayStateUI the name of a class you created? If so, are you just asking if that's a good name for a class? –  Cameron Fredman Feb 20 '13 at 2:47

1 Answer 1

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.

share|improve this answer
    
+1 It's a good a suggestion as any. –  Byte56 Feb 20 '13 at 6:16
    
Thank You. That was the answer I wanted to hear. Now it makes sense. –  user2055675 Feb 20 '13 at 13:15

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