vendredi 7 février 2020

should a data model hold a controller? (MVC)

I'm implementing a game in which a player has a boat and he needs to move with his boat and collect some stuff. the player has score and life as well.

I designed the system as the MVC pattern and right now I have a boatModel object which holds the data about the boat, BoatController which responsible to handle movements.

I considered making a PlayerModel object which holds the data about the player, including life, score, and the BoatController. that's because conceptually the player has his own "boat driver"

Is it make any sense that's a model object "has-a" controller (according to the MVC pattern)?

If not, how it'll be better to design it?

Thanks.

Aucun commentaire:

Enregistrer un commentaire