+ 2
Help me with a game code
I am new at programming and Python. I'm trying to develop a simple RPG in text for a project and I don't know how to fix the repeating question(Character name) without messing up. https://www.sololearn.com/pt/compiler-playground/caP0b145CR7L
3 Answers
+ 3
Nice little game with a plot there
I'm actually not too sure what you meant by "fix the repeating question(Character name) without messing up.".
Generally, in such a setup, game begins with role selection (Warrior, Mage, Archer, Rogue etc.) Once a role is chosen, a character for the player is created by prompting for a name. So these two steps don't need to be repeated, unless you want to support multiplayer with different roles.
Assuming a character had been created for current player, a loop can then begin, which may prompt the player for an action (go left/right etc.), and a random "event" can take place depending on the action chosen.
This is as much as I understood about such a game play. I could be wrong, but perhaps not too far :)
So, can you point me to more detail about your fear for "messing up" for my better understanding?
+ 2
I'm new at coding and I'm always afraid of trying to fix my code. So one thing I notice is when I play to run the prompt for the name of the character appears two times. Thank you for your consideration!!
0
Function start_page() asks for player class, function create_character() asks for character name, and class. Prompt for character name occurs once only, in the create_character(). It was prompt for class that was repeated, once in start_page(), once in create_character().
I would prefer to remove or comment part of start_page() which asks for player class, and rely on create_character() for the prompt of player class and name.
You can show the "Let the adventure begins" message after the player has been created.
Don't be afraid of making changes to your code, coders do that, and it's something common to do. If you want, you can make a backup of the code before making changes, that way you can revert to previous version in case you wish to.