From: Henry Maddocks Date: 2012-09-25T07:09:34+09:00 Subject: Re: still learning by doing - connecting rooms in a game On 25/09/2012, at 8:05 AM, Jesús Gabriel y Galán wrote: >> >> If there is another way I can reference these objects? If I initialize >> an object like player in the room itself it is again limited to the room >> in question, right? > > I don't think the Room is the right place to initialize the player > object. The player object probably belongs to a Game object or such. > What you can do is pass the appropiate objects where they need to be > used. In games, and a lot of other types of program, there is usually a 'god' object or controller object that is tasked with 'running' the game. This object initialises everything (builds the rooms from the map, initialises the player object) and then enters the game loop. In the inner game loop the GameController receives input and then iterates through the game objects (rooms, player, etc) updating their state. I true MVC style the rooms and the player don't need to know about each other. All the interaction is done inside the GameController object. Henry