Branching paths for a text based adventure game (language agnostic)
How would i create a system of branching paths for a text based adventure game? i dont want it to devolve into a ton of if-statements because i have done that before and it is a mess to keep track of and maintain
7 Replies
Splitting stuff into methods can flatten the structure a lot
and facilitate code reuse
For example:
Instead of having everything in the
City
methodoooh functional programming
i like that idea
ima experiment with that and come back to you
i have no idea what this error means
looking up its code doesnt get me anywhere
Means it could not automagically figure out what type to infer
That's why my example specified the type to be
Action
instead of using var
ah ok
i believe a common way would be having engine+branching data, instead of the path being directly implemented in the code
so the data would have a pointer to where to go next, a bit like the adventure card games where there's writter "if you answered A pick card 48"
so with that idea it would be more like
?
if the adventure is short i would maybe go for a simpler approach
if there are scenes, chapters, plots, then i would move it to data, like