Tuesday, July 2, 2013

Dev Log: Horror Text Adventure #13

Mostly been trying to figure out items. Items are basically everything, I've decided: a poster on a wall is an item, a key is an item, a bed is an item, etc. Then each item has a "takeable" boolean, a description vector of strings (separate sentences, so if one sentence changes I can change that part, I think), and a "container" boolean. The container boolean basically is whether the item can contain other items (like a treasure chest).

I spend a lot of time hemming and hawing over how to make the content itself. I considered text files that would be read in, but that was 99% just for making it easier for me to type up.  I am unsure how best to code something like that, with most tutorials I see load the file into memory, and it doesn't work for large files. I don't know how large such a file would be, but even so, it's really not necessary to go through the trouble just so I can write item descriptions easier.

So instead, I've done it in good ol' fashioned AS3 code, with lovely switch statements and the random function to pick descriptions for items. I expect the same will work for room descriptions, as well.  So it doesn't look pretty; I think it works well enough.  I think there should be a way for me to squeeze the switch statement by eliminating one more repeated line (just a vector.length++ line that really needs to go), but I'll figure out the proper way to do it sooner or later (preferably sooner).

I guess now one of my concerns is making more universal statements. I mean, why repeat "There is a bed here" and "There is a chair here" when I can type "There is a [item] here" and have the code take care of all that?  But the two tricks I need to learn is making upper and lower case properly so it doesn't say "There is a BED here" or garbage, and also determining, with more descriptive ones, which ones go where ("The TOILET PAPER is RUSTY" should not occur... although that would certainly be disturbing).

I'm sure there is lots more to specify with items, but it's a start. My hope would be that items can be made universal, and perhaps I can add the names to the dictionary to help work the text parser. Ah, well, interconnectedness shall be biting me, I am sure.

No comments:

Post a Comment