I tried creating a function that checks input so that I wouldn't have to write a billion if statements, however I don't quite understand how I'd plug the next part of the story into the function.
Should I turn this function into a string that returns the userinput, and make another function that checks it's return output? That way, based on what's returned it could print out the next part of the story? How exactly would I be able to achieve this because I'm confused. Is there an easier way to do this?
I'm sorry if my question is hard to understand, I'm not very good at explaining things.
I think you can call whatever you want to do next from this function - like showing story etc.
In case you use the return value of this function in the called function, you will probably need to use a switch in the called function too, to decide on the action. This will make the code redundant.
and you have to make state is a list of story-board, defined by number. Maybe detail stored in arrays or files.
like
1: begin : yes->2, no->3
2: select mom : male -> 4,female->5
3: go to hell
4: happy
5: select dad ...
...
I like the story-board idea a lot though, and I'm going to try it out. I think what I'm going to do is once it passes through the if statement, a number is a signed to an int. The int is then checked for by a switch statement, and will print the next part of the story based on the number... Or is that too complicated, and would it be easier with arrays or files? I'm still learning about files, but so far they don't seem too complex, so I might try that out.
Thank you both so much for your help!
EDIT: I now realize that my way of trying to do it is way complicated.
EDIT 2: I've decided that the input checker is only going to check for the words "MENU", "EXIT", and generate an error message when userinput != answer1 & userinput != answer2
It's not much complicated about coding.
For my experience in coding game (especially in Assembly), the story-order-in-line and story-special-action-to-user is much harder.
(story-order-in-line is just like my last example, if you have 100 state maybe state 50 have to direct to state 99 and 100 will make you confuse if you decided it not good enough.)
How to response to player is what you have to decide in separated function.
So function state-selector is just function used for choose the way game will go on, and which function will be used to response.
So I'll make a function with all the story lines, and the selector to choose a storyline based on provided input. That sounds a lot easier than what I was trying to do, thank you so much!
By the way, thanks Disch. That links kind of provides me of a better understanding of how files would work in this situation.
I'm going to go try all of this out and I'll let you know how it goes.