From 3483748f8e33d31217ab048c2e2960bec2f85139 Mon Sep 17 00:00:00 2001 From: waldek Date: Fri, 29 Oct 2021 09:24:46 +0200 Subject: [PATCH] adds progress bar link --- examples/ex_text_based_adventure_game.py | 45 ++++++++++++++++++++++++ learning_python3.md | 2 ++ 2 files changed, 47 insertions(+) create mode 100644 examples/ex_text_based_adventure_game.py diff --git a/examples/ex_text_based_adventure_game.py b/examples/ex_text_based_adventure_game.py new file mode 100644 index 0000000..3e45a57 --- /dev/null +++ b/examples/ex_text_based_adventure_game.py @@ -0,0 +1,45 @@ +answer = input("You're at a cross section. Do you go left or right?") +if answer.startswith("l"): + answer = input("Down this hall you encounter a bear. Do you fight it?") + if answer.startswith("y"): + print("The bear counter attack! He kills you") + print("game over!") + exit(0) + elif answer.startswith("n"): + print("It's a friendly bear! He transforms into a wizard!") + answer = input("The wizard asks you if you know the meaning of life?") + if answer == "42": + print("He knods approuvingly and upgrades you to wizard status!") + print("You win!") + exit(0) + else: + print("He shakes his head in disbelief. You fool!") + print("game over!") + else: + print("that's not a valid choice...") + print("game over!") + exit(0) +elif answer.startswith("r"): + answer = input("Down this hall you find some mushrooms. Do you eat them?") + if answer.startswith("n"): + print("You starve to dead...") + print("game over!") + exit(0) + elif answer.startswith("y"): + print("A wizard apprears out of thin air!") + answer = input("The wizard asks you if you know the meaning of life?") + if answer == "42": + print("He knods approuvingly and upgrades you to wizard status!") + print("You win!") + exit(0) + else: + print("He shakes his head in disbelief. You fool!") + print("game over!") + else: + print("that's not a valid choice...") + print("game over!") + exit(0) + pass +else: + print("game over!") + exit(0) diff --git a/learning_python3.md b/learning_python3.md index 39ab1be..448d91d 100644 --- a/learning_python3.md +++ b/learning_python3.md @@ -583,6 +583,8 @@ TODO [db](https://opentdb.com/api_config.php) TODO add a countdown timer to the multiple choice game +* how apt does it's [progress bar](https://mdk.fr/blog/how-apt-does-its-fancy-progress-bar.html) + # GUI programming ## wxpython helloworld