Tuesday, September 3, 2013

Dev Log: Horror Text Adventure #18

I did a little bug-fixing and house keeping on the text adventure.  First, I reordered the Main code so the display function was called last, after the rooms were made, so the directional description displays properly (so the player knows there is a room connecting it).  I also added a couple more ways to let the player type to move, so they can say "move", "go" or "head" and then a direction to get where they want to go.

The big thing was cleaning the code and dramatically reducing the size, both in the Room class and the Interface class.  I finally broke down and changed the six directional pointers (which connect rooms together in a doubly linked list) into one vector of rooms pointers.  Since the pointers are no longer named by direction, I have to put in a comment that 1 = North, 2 = East, etc. But it saves a lot of room so I'm not duplicating code, and can instead reduce large If statements into quick For loops.  I think I may have cut around 50 lines of code by doing that (and I perhaps more will be saved in the future).  It's a trade-off between cleaner code versus readability, but I think it was worth it.  I do want to find a way to fix one more bulky section dealing with that, but I don't think it matters too much just yet.

Now, didn't I promise being able to take objects last time?  Next time...

No comments:

Post a Comment