I am currently a student in the DigitalCrafts full-time Web Development course. We just wrapped up week number three and our very first solo project. The assignment was to create a terminal based game using Python.
My daughter and I are currently watching the first season of the A-Team together. If you are unfamiliar with the show, it is an old network television show from the 1980’s. The show was about four men who were members of an army unit during the Vietnam War. They were sent to prison for a crime they didn’t commit. After escaping prison, they survived as soldiers of fortune in the Los Angeles underground. Every episode revolved around The A-Team helping some unfortunate soul who was being bullied by some prototypical television bad guy and his gang of goons. Despite the otherworldly amount of car crashes and guns fired, no one ever appeared to suffer anything worse than a black eye and all problems were neatly solved within the hour episode. If you are looking for high-cultured entertainment, this ain’t it.
A-Team the Game
I used the show as inspiration for my Python project. The goal of the game is to help the Penhall family get their last crop of watermelons to the L.A. Farmers Market. Stopping them is the evil rancher Chuck Easterland. Chuck wants to force the Penhall family into foreclosure so he can purchase their farm for pennies on the dollar and expand his ranching empire.
In my game, you can choose to be one of two characters from The A-Team, either John “Hannibal” Smith or B.A. Baracus. I created classes to give each character different strengths and weaknesses. For instance, B.A. Baracus has higher “strength” capabilities versus Hannibal who has more “brains”. The game is entirely text based. You help accomplish the game goals by fighting, retreating, and tricking Chuck Easterland and his merry band of buffoons. Besides classes, I also used while-loops, functions, and if/elif/else statements. I also imported the time, random and PIL.Image libraries to increase the functionality of my program. Finally, I was also able to add a little bit of ascii art to the project at the eleventh hour.
def fightToughBadGuyWeakGoodGuy():
hannibal.health = 10
toughGuy.health = 10
toughGuy.health = toughGuy.health - hannibal.power
print("\nYou hit him hard, but unfortunately not hard enough, Bubba is still on his feet and he appears to be slightly irritated with your ruse\n")
time.sleep(2)
print(f"<<<<<Your health is now {hannibal.health}>>><<<Bubba's health is now {toughGuy.health}>>>>>")
x = (input("""\nWhat should you do? Should you:\n
A = make like a shepherd and get the flock out of there\n
--or--\n
B = give the big lug another slug\n
"""))
if x == "A":
print("\nWhile lunkhead is still trying to figure out which way is north and which way is south, you decide to cut your losses and beat it to the chopper. After all, you've always been more of a lover than a fighter. You sprint to the helicopter and jump into the cockpit. Adhering to television show rules, the keys to the copter are in the visor. You fire up the huey and make your getaway while Bubba shakes his fist at you in vain. Smell ya later!\n")
time.sleep(5)
sceneTwo()
elif x == "B":
print("""
you take another crack at the big burly behemoth.\n
WHAP!
""")
randomHealthBonus = random.randint(1, 10)
toughGuyHealth2 = toughGuy.health + randomHealthBonus
toughGuyHealth3 = toughGuyHealth2 - hannibal.power
if toughGuyHealth3 > 0:
print(f"This guy appears to be getting stronger as the fight continues! He's a savage! <<<<<Your health is now {hannibal.health}>>><<<Bubba's health is now {toughGuyHealth3}>>>>>""\n")
print("You gave it your best shot and he's still on his feet! This guy can't take a hint! Should you:\n")
y = (input("""
A) give him the Kung Fu Grip Death Punch\n
--or--\n
B) make like a banana and split!
I also imported the time, random and PIL.Image libraries to increase the functionality of my program. Finally, I was also able to add a little bit of ascii art to the project at the eleventh hour.
Challenges I Encountered
One of the challenges for this project was the size. This is the most amount of code I have written in a program to date. The second biggest challenge was maintaining proper indentation. The nesting of if-statements inside of while-loops inside of functions made keeping track of indentation tricky. Luckily, a classmate of mine told me about a VS Code Extension that helps with this issue.
Areas For Improvement
There is plenty of room for improvement. My original plan was to allow the player to choose to be any of the four members of The A-Team. In addition, my original planning session had three main acts or scenes. In the interest of fulfilling my deadline, I scaled back the scope of my project to only include the two main characters and two scenes. As I continue working on this project, I will develop the other two characters that make up the team and add the third “act”. In addition, after the project was over, I learned that you can link python files together. This will be another improvement to incorporate as I continue to improve the project.
Overall, I think our instructor picked a great project for us to complete. We had only studied Python for a week, so our toolbox was limited. However, we had enough of a foundation to create a functional game. The project also provided an opportunity for additional independent learning to discover more efficient ways to work around problems and find alternative solutions.
References and Resources
If you would like play the game, you can check it out on my github account:
https://github.com/JAReichert/digitalCrafts/tree/master/aTeamPythonGame
Also, I’d be remiss if I didn’t give a thank you to my classmate, Rayleigh Rozier, who pointed me in the direction of the VS Code Extension Identicator. You can find Rayleigh’s awesome college football game here:
https://github.com/rayleighrozier/digitalcrafts/tree/main/dawgsOnTop
Here is a link to digitalCrafts:
Finally, check out this youtube video from Caelan at Kite. It is a tutorial on how to turn any image into ASCII art. It was a big help in jazzing up my primarily text based game with some artwork.
Top comments (0)