I intend to make a choose-your-own adventure game purely in text. The thing is I've never worked in a compiled language before (or even one that accepts user input while running), only interpreted/web (run-once) languages. I'm unsure how to properly make branching paths of choices. Not simply a choice and then continuing along the same path, but branching paths.
For something simple (say a 3-step story) you could just keep a path number in a variable and use conditionals to display the right path, as in this pseudocode.
Thing is as more and more choices become available within the story that can get rather messy, so I'm curious to know if there's any better way to do this, or if I'm on the right (basic) track.
As for keeping track of the paths and such I'll be using an external program, FreeMind.
For something simple (say a 3-step story) you could just keep a path number in a variable and use conditionals to display the right path, as in this pseudocode.
Code:
displaytext("hello");
givechoice("cake","pudding");
if ("cake") {path=1;}
if ("pudding") {path=2;}
if (path==1) {
displaytext("Do you eat the icing or cake first?");
givechoice("icing","cake");
if ("icing") {path=3;}
if ("cake") {path=4;}
}
if (path==2) {
displaytext("What flavor pudding?");
givechoice("vanilla","caramel");
if ("vanilla") {path=5;}
if ("caramel") {path=6;}
}
if (path==3) { displaytext("That's not the way I eat cake."); }
if (path==4) { displaytext("That's the way I eat cake."); }
if (path==5) { displaytext("Nothing special?"); }
if (path==6) { displaytext("That's one of my favorites."); }
As for keeping track of the paths and such I'll be using an external program, FreeMind.