This semester in DTE we have been learning about robotics and coding but due to covid, we missed out on doing some of the other lessons.
Recently we had been tasked to make a project that we would work on as a group and present at the end. I had at the time been thinking about learning about more in-depth python coding; so I chose to make a text adventure game in it. Because I hadn't done anything as complex in code I chose to make a pick your own path adventure game. Some of the paths that you could explore were: A horror story, A Medieval story, A story about the future and A story about the present.
We used coggle to plan how the story would go and where they would branch out. andrei one of my friends decided to join and help in writing the story as I am terrible at writing storylines. Andrei and I worked on the story, and I started to code. Around this time Kade joined and he was the beta tester.
This is the coogle.
Kade helped with getting the code running well as he was very good at finding bugs. he also taught me that no is always an answer so therefore I made it so that no matter what you put in it will always give you an answer. Some other things I learned is how coding works for instance.
The code runs on the python 3.10 version for windows. And mainly consists of if, else and input statements.
The statements together allow the script to run and play.
Some samples of the code are.
Answer = input (“hi how are you?”)
If answer == “good”
Print (“good”)
This code here when put into python and ran will ask: Hi how are you? And by responding with good python will return good.
This happens because of code! The best way I could explain this is as:
Answer = input: Is a prompt that asks for input from the user and whatever that input is it gets recorded under answer. The “if” statement asks if the answer is equal to “good” and “if” it is then it’ll print “good” back.
The else statement comes into play when there’s more than one input of instance:
Another type of statement is the “def” stamen that “defines something”.
Answer = input (“How are you today?”)
If answer == “good”
Print (“that’s good”)
Else;
answer == “not good”
Print (“that's not good ”)
This code will ask for an answer-back but now if you answered “not good” back then it’ll print “that’s not good”.
def restart():
print ("Do you want to play agin?")
answer = input ("")
if answer == "yes"
start_of_game()
This code will at the end of a string and will ask if you want to play again. The “def” statement is very interesting as it allows you to write some code that you don’t need at the moment but can be called upon later when it's needed. It's used as such.
else:
answer = "no"
print ("hell no. Yeah, you've had enough anxiety for now. you leave.")
restart()
In this part of the code this is an ending but with the “restart()” it allows you to restart. But this is just the subsurface of coding. There are many different types of coding languages and there’s many more commands and modules to use in code. Currently,the code is about 564 lines of code but I'm thinking of adding ether more or making a GUI that had buttons so that you don't have to type in the answers.
The link to the files can be found here.
link to drive folder with code