How would buttons in a Chose Your Own Adventure Game work?


I’m not vary strong at programming but I know some basic stuff. I’m making a Chose Your Own Adventure Game and I can’t figure out how the buttons would work. I think an Array and For Loop would work but I have no idea how to write something like that.

Example: You have a choice of 2-6 buttons you chose one then all the buttons and story text turn off and then more story text and buttons turn on.

Thank you to anyone that helps out I really appreciate it.

You might want to look at linked lists and custom classes. Something like:

class MyDialog
    string Text;//Test to display
    string Answer1Text;//Answer 1
    string Answer2Text;//Answer 2
    string Answer3Text;//Answer 3

    MyDialog Answer1;//Reference to the dialog to display on answer 1
    MyDialog Answer2;
    MyDialog Answer3;


You would also need to have a dialog manager that keeps track of the current display dialog as well as initialize the UI elements:

MyDialog first = new MyDialog();
first.Text= "You are in a dark room. Do what?";
first.Answer1Text="Go foward";
first.Answer2Text = "Go back";

MyDialog a1 = new MyDialog(); 
a1.Text = "You have gone forward and find a wall";
a1.Answer1Text = "Smash wall";
a1.Answer2Text = "Inspect Wall";

MyDialog a2 = new MyDialog(); 
a1.Text = "You went back and fell";
a1.Answer1Text = "Get up";
a1.Answer2Text = "Stay on the floor";

first.Answer1 = a1;//Chain the dialogs

There’s many different ways of doing this task and this solution might be a little tedious but the concept is sound. There’s also more coding involved like reacting when an answer is selected to advance the current dialog, etc.

Here’s info about Generic UI Elements:

Easy to understand info about linked lists: