Tuesday, September 10, 2013

Dev Log: Horror Text Adventure #19

The player can now pick things up. Woot!

It was mostly just a question of comparing the second word of a "take <item>" command with the names in the room's item vector.  If it matched, push the item to the player's inventory and splice it out of the room's.

Now, however, the big problem is becoming capitalization.  Just to make things easy, I originally made it so everything had to be typed in lowercase, but I didn't think about that when I made the item names in caps.  So the player couldn't pick anything up without saying "take <ITEM>"!  For now I just changed the items to lowercase names, but I think next I really need to make that more convenient.

So next up will probably be taking the player's input and passing it through some kind of filter that takes every letter and makes it the uppercase version of that letter (unless it already is).  It shouldn't be tough to simply subtract 32 from the ascii code of any letter with a value between 97 and 122; the main thing is getting one letter at a time from the input.  I already chopped it up into individual words, but I'm thinking what I may have to do is cut it into chars, send it through a case switcher (not to be confused with case switches!), then slam it all back together, before THEN passing it on to the word chopper.

I'm sure I've also got a few bugs to fix with the player taking items code (like the room description needs updating), so I've got a bit of mechanical cleanup to do before getting into a new mechanic or feature.

No comments:

Post a Comment