OK I was thought in my youth that global variables is a crime against all that is holy. As I'm working my way through my less-than-epic Dungeon Crawler I am starting to think this might not be a 100% true:
The main screen of my game is called dungeonView and is controlled by a dungeonViewController. I have created a player-object handling stuff like stamina, strength etc. as well as a few methods. I haven't really hit a brick wall or anything yet, but I find passing the Player Object instance around dungeonViewController's different methods fairly tedious, especially as there is never more than one instance of Player in existence.
It has occurred to me that the existent of one global Player instance would be beneficial and I'm actually having a hard time finding any strong argument against this idea. Anyone disagrees? And if not, could anyone enlighten me on where I would init the instance? (Perhaps in the dungeonViewController's init-method?).
Any feedback is more than welcome.
The main screen of my game is called dungeonView and is controlled by a dungeonViewController. I have created a player-object handling stuff like stamina, strength etc. as well as a few methods. I haven't really hit a brick wall or anything yet, but I find passing the Player Object instance around dungeonViewController's different methods fairly tedious, especially as there is never more than one instance of Player in existence.
It has occurred to me that the existent of one global Player instance would be beneficial and I'm actually having a hard time finding any strong argument against this idea. Anyone disagrees? And if not, could anyone enlighten me on where I would init the instance? (Perhaps in the dungeonViewController's init-method?).
Any feedback is more than welcome.