We are about to switch to a new forum software. Until then we have removed the registration on this forum.
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
https://padlet-uploads.s3.amazonaws.com/prod/144491594/2cec507f23ff7ac1ce06043d2682c74e/Storylines.html this is a example of something what we would like to get.
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?
http://studio.SketchPad.cc/sp/pad/view/ro.9eDRvB4LRmLrr/latest
https://forum.Processing.org/two/discussions/tagged/multipage
How to make an interactive storytelling game / Textadventure
The naiv idea is to have huge list of
if
s 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:
What to do then
Now you load all lines from your hard drive in an array (see
loadStrings()
in the reference; Usesplit()
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 indexcurrentPage
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 / ArrayListpages
of thatclass 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 theclass Page
.Best, Chrisir ;-)