How do you program a name into a text-based-game?

Hey, I'm trying to make a text adventure based game! I want it be where someone can type in their name and their name appear in a sentence for the rest of the game. How would I be able to pull something like that off.

Answers

  • You'd have to store the name in a String variable, and use the contents of that variable whenever your game wants to display the name again.

  • You need states in your program

    One state is help screen one is high score one is game itself, one is eg. enter user name.

    In draw() use switch to use the states

    To enter a name say name=name+key;

    When enter is pressed, say state = Game;

    Before setup() :

    final int Game=0;

    final int enterName=1;

    int state=enterName;

Sign In or Register to comment.