Tuesday, March 4, 2014

Dev Log: Horror Text Adventure #41

Got rid of a ton of code and made things far simpler.  I took all the repeatable school things I could and shrunk them down to size with loops (connections and stuff).  There are a lot of other things that are specific that don't take well to loops, but hey, cutting out 43 lines of code and replacing it with a couple of for loops and if statements is awesome.  Well, I had to make a 2D array as well, but worth it.  In the long run, this is definitely the better way to do it.

I also cleaned up code a little more, by making things slightly longer but more readable.  In the background, directions are just numbers, so 0 is north, 1 is east, etc.  But every time I try to use those numbers, I have to sit there and think about which is which or look it up, so I altered functions where I could so I could just put in a string for readability.  The function is now longer (used to be like one line), but it is far easier to read.  In fact I've been fixing errors for a while because I forgot to start at zero in places, so things would get all mixed up.

But once that stuff got fixed, I was able to take a tour of the school.  Mostly empty, of course, but working.

I also added a statement when you walk into a new room it tells you what type of room you've just entered.  I can't believe that was missing.  At first I thought something was wrong in the school when you walked into a classroom or office, because no description was given, but that was just because they have no items in them yet.  It didn't help that hallways always have a painting in them (which they shouldn't), so their description wasn't blank.

Next comes making it so common areas don't randomize items on instantiation, while unique areas do.  Then I might be able to get to making items to fill in the rooms.

No comments:

Post a Comment