How can you organize the code for a game to fit the MVC pattern?

前端 未结 6 2080
面向向阳花
面向向阳花 2020-12-22 15:46

I\'m a freshman in college going for my computer science degree... I\'ve programmed plenty the last several years but just lately I\'ve been getting more into theoretical id

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-22 15:56

    My way of thinking of MVC is as MDUC
    Model
    Display
    User-input Controller

    The model contains the domain model objects
    The display shows the current state and behaviour of the domain model objects on-screen.
    The user-input controller handles all the user inputs.

    It's exactly the same pattern, but the names are just ever so slightly more descriptive, so I find what responsibilities each part of the pattern has is clearer, and so the meaning of the pattern is more memorable.

    Once you see that you are splitting data and model operations from displaying, from the user's inputs, it's easier to see where to group what in your own code.

提交回复
热议问题