Saturday, November 6, 2010

Ok, later (now, with EDIT!)

I really want to make a choose your own adventure-esque story. Literally. I need to find/download a cheap compiler or something. The logic isn't too hard, but depending how sophisticated you want it to be, it'd be labor intensive.

Basically, it seems like it runs on a bunch of switch statements--switch statements literally can "switch" the flow of the program. In this case, the program waits for input from the keyboard (probably a cin to a string, but I think it'd be much easier with a cin to a char, only that's not as interactive). Anyway, based on this input, choices happen.

so, for example:

string decision;
cout<<"Text to respond to\n";
cin>>decision;

switch (decision)
{
case "option 1"
do_this();
case "option 2"
do_that();
.
.
.
default
cout<<"That is not a valid choice--please try again\n";
}

So, as you can see, not really "hard," in theory, especially if you do limit it to picking a specific letter choice. Can probably cut the work load by breaking the story into separate header files or different functions, but then again, nesting stuff is weird. Hmm.. Some pseudocode I may come back to:

//includes--iostream; maybe external defined files to compile with
void main(){

char decision; /*i think i may only have to define this one variable, since everything will be menu driven/dynamic, i just need to make sure i properly change the value*/
bool not_finished = 1; /*ok, i lied--booleans hold either 1 (true) or 0 (false)--the logic should be clearer later, but while, literally, the story is not finished, continue to run the story*/

cout<<"long introduction; compelling; wizards and goblins"<while(not_finished)
{
first_part_of_story_function_call(decision); /*obviously, in each function call, I have to remember to return a decision (passing a char isn't bad...just remembering it may be a problem, ha).
.
.
.
.
last_part_of_story_function_call(decision);
not_finished = 0; /*looking at the code now, since I'm not really looping, I don't even think i need the "not_finished"--I guess that limits the story. But then again, I could have the option here to run the story again (e.g., cout<<"'Play' again?' Y/N), which could take a char input and switch, e.g., case "Y" not_finished = 1 (which, really, I could probably just use a break statement, as its value is already 1) case "N" not_finished = 0; hmm, decisions.
}

return;
}

Anyway, maybe I'll bring this up in class and make an executable that can be hosted...I was thinking of trying to find Flash to do something cool with the other collaborative exercise, but while I still understand the logic behind ActionScripts, I've forgotten much in terms of tweening and other Flash specifics stuffs.

Hmph.

-Glenn


EDIT



So, created a quick version--not my mastertape, per se, but a representation from class. Not too bad to code, just tedious (as I haven't coded anything, really, in about 4 years). There's some visual stuff I want to work out, but for a command prompt with strict decisions, I think it's ok. I have to figure out a way to host the executable (and I'm not sure it will work on macs).


---

UK - In the Dead of Night

Prog deliciousness. Allan Holdsworth--c'mon!


No comments:

Post a Comment