How to make an interactive storytelling game with buttons that open a new screen?

edited November 2016 in How To...

Me and 2 friends are new to processing and need to make a project for school. Ive been looking around the internet for a way to make our plan happen. Our plan is as follows: We want a screen with 4 buttons, if you press one button you go to another screen with diffrent choices and repeat. i know how to make a button but dont know how to get the button to open a new tab

Answers

  • we would like to make an interactive storytelling game which the player influences the end of the story with clicking on the buttons on screen, is there a command that allows us to make a button open a new screen?

  • edited July 2017 Answer ✓

    How to make an interactive storytelling game / Textadventure

    The naiv idea is to have huge list of ifs in your sketch. Soon you will not be able to maintain the code. It just gets too big.

    Instead, you need to make a data structure to hold the story and the branches (decisions of the player) in the story.

    data structure

    The data structure can be a simple text file (or table). Each line in the text file represents one room in your game or one situation etc.

    The line in the text file holds these information:

    • Text for the page (e.g. "You are at a dark Tower. One Path leads west, one south. Which one do you choose?")

    • Text for the 4 buttons (e.g. go west, go south...)

    • Information about where the 4 buttons lead to. These can be the line numbers for the text lines we need to jump to depending on the decision of the player: line numbers for 4 pages (A).

    • additional information, e.g. color for background, a audio file to play, an image.

    An example for a text line could be:

    "You are at a dark Tower. One Path leads west, one south. Which one do you choose?","go west","go south",13,25,"windBlows.mp3"

    What to do then

    Now you load all lines from your hard drive in an array (see loadStrings() in the reference; Use split() to split the lines up at the commata , ).

    You set an index currentPage (e.g.) to the first line and display the text ("You are at a dark Tower...") and the buttons ("go west","go south"). Depending on what the user clicks you jump to the next line number setting index currentPage to the value from the text line (13 or 25 in the example).

    When you know objects/ classes: make a class Page to gather the data. And an array / ArrayList pages of that class Page. This object oriented programming approach is not strictly needed though.

    (A) above is used for changing the index for that array.

    Have one int currentPage; as this index.

    Depending on button clicked set currentPage to value of the button clicked by the user (see A).

    Display current page as

    pages[currentPage].display();

    And write display() as a method in the class Page.

    Best, Chrisir ;-)

Sign In or Register to comment.