Tuesday, August 13, 2013

Dev Log: Horror Text Adventure #16

I've got rooms to connect back and forth via doubly linked list, so it should be possible to move from room to room.  Except that I'm trying to figure out exactly how to implement the dictionary.  Well, not how, exactly, but where.  Make the dictionary a static function or a singleton?  Or include it in the Interface class?  At first I had it in the Interface class, and that works great for getting things to show up on the screen, but it has a hard time talking to the player.  So I think if it stayed in the Interface class, I'd have to jump through hoops to move the player from room to room, and probably to make the player pick up objects and all that stuff.

I did see a neat trick while I was trying to figure out the best implementation: upon instantiation of that object, include as a variable a pointer to the other stuff I need.  So if I had a Dictionary class (or if I keep the dictionary in the Interface), I add a pointer to the player on instantiation, and that allows me to use it as I please on a whim.

Pointers! And I've been using pointers for rooms this whole time!  I should be able to implement that without too much trouble, and see where it leads me.  It would certainly be cleaner than keeping it in the Interface class, which gets clogged if I do.

No comments:

Post a Comment