Experience the excitement of a realistic penalty shoot-out game from your terminal with our interactive game. This project aims to design an immersive experience that allows users to engage in a simulated penalty shoot-out, making strategic decisions just like in an actual game. The game was created with Python, highlighting the language’s flexibility and strength. This is part of the third portfolio project of the Code Institute course.
The primary focus of the target audience is football enthusiasts, gamers, and anyone intrigued by interactive command-line games. Whether you are a seasoned football fan wanting to simulate the thrill of a penalty shoot-out, a casual gamer looking for a quick and fun distraction, or a Python learner interested in seeing what the language can do, this game is for you.
Immerse yourself in penalty shoot-outs from the comfort of your desk. The game goes beyond mere victories or defeats. It is about the path you take and the choices you make. It combines strategy and chance, recreating a real penalty shoot-out’s unpredictable nature and high stakes. Each decision you make, whether shooting or guarding the goal, can alter the game. The game is designed to be interactive and enjoyable, regardless of your football knowledge or gaming proficiency.
Source: amiresponsive
In this project, I follow the Five Planes of User Experience model invented by Jesse James Garrett.
This model aids in transforming from abstract ideas, such as creating objectives of the project and identifying the user needs, to concrete concepts, such as assembling visual elements together to produce the visual design of the idea to meet the project’s objectives and users’ needs.
This project centred around creating a captivating command-line game that mimics the experience of a football penalty shootout. This game was designed to entertain players, challenge their decision-making abilities, and showcase Python’s development potential.
The game was designed to incorporate essential elements of a penalty shootout. The included elements are the coin toss for determining who goes first, choosing the target area, deciding which area to defend, and calculating and displaying scores. The game was created to be replayable, offering unique outcomes in every playthrough.
Please refer to the Data Model section for more detailed data model.
The game’s interface is text-based. Information is presented to the user in a clear and organised manner. The purpose of user input prompts is to be straightforward and clear. The implementation of error handling helps direct the user to valid inputs.
Click here to view the live site.
When the file is loaded, this is the first page that features the ASCII image of Penalty Shootout with instructions for the game. Ultimately, the game asks the player to input their name before starting. Also, it displays the error handling message to guide the player in inputting the correct one.
Start | End |
---|---|
- |
The coin toss allows the game to determine who should take the penalty kick first. It contains the coin that gives the player a head or a tail. Once chosen, the game will display the outcome of the coin toss with a green or red background to tell if you have won or lost the coin toss. Also, it displays the error handling message to guide the player in inputting the correct one.
Start | End |
---|---|
The penalty shootout game starts with either the player or the opponent taking the first penalty kick based on the outcome of the coin toss result. The game displays the ASCII image of the goalpost guiding the player of a target area to save or to score depending on their turn. It will then display whether the player scores as a penalty kicker or save as a goalkeeper. Also, it shows the error handling message to guide the player in inputting the correct one.
Start | End |
---|---|
Whoever scores 5 goals within 10 turns or has a +1 goal advantage with more than 10 turns wins the game. The result will be displayed whether the player wins the game or not. Finally, the player will be asked whether to restart the game or exit the game. Also, it shows the error handling message to guide the player in inputting the correct one.
Start | End |
---|---|
- |
git add
, git commit
, git push
)To follow best practice, a flowchart was created for the game’s logic, and mapped out before coding began using a paid version of MyDraw.
Below is the flowchart of the main process of this Python program. It shows the entire cycle of the program.
The primary functions used on this application are:
clear_old_term()
request_player_name()
main_menu()
toss_coin()
print_goalpost()
print_goal()
print_save()
print_win()
print_lose()
choose_goalpost()
play_game()
game()
I have used the following Python packages and external imported packages:
os
: used for adding a clear_old_term()
functioncolorama
: used for including color in the terminalrandom
: used to get a random choice from a list[!NOTE]
For all testing, please refer to the TESTING.md file.
Code Institute has provided a template to display the terminal view of this backend application in a modern web browser. This is to improve the accessibility of the project to others.
The live deployed application can be found deployed on Heroku.
This project uses Heroku, a platform as a service (PaaS) that enables developers to build, run, and operate applications entirely in the cloud.
Deployment steps are as follows, after account setup:
PORT
, and the value to 8000
then select add.Python
first, then Node.js
second. (if they are not in this order, you can drag them to rearrange them)Heroku needs three additional files in order to deploy properly.
You can install this project’s requirements (where applicable) using:
pip3 install -r requirements.txt
If you have your own packages that have been installed, then the requirements file needs updated using:
pip3 freeze --local > requirements.txt
The Procfile can be created with the following command:
echo web: node index.js > Procfile
The runtime.txt file needs to know which Python version you’re using:
python3 --version
in the terminal.python-3.9.18
For Heroku deployment, follow these steps to connect your own GitHub repository to the newly created app:
Either:
Or:
heroku login -i
heroku git:remote -a app_name
(replace app_name with your app name)add
, commit
, and push
to GitHub, you can now type:
git push heroku main
The frontend terminal should now be connected and deployed to Heroku!
This project can be cloned or forked in order to make a local copy on your own system.
For either method, you will need to install any applicable packages found within the requirements.txt file.
pip3 install -r requirements.txt
.If using any confidential credentials, such as CREDS.json
or env.py
data, these will need to be manually added to your own newly created project as well.
You can clone the repository by following these steps:
git clone https://github.com/RoBizMan/penalty-shootout-game.git
Alternatively, if using Gitpod, you can click below to create your own workspace using this repository.
Please note that in order to directly open the project in Gitpod, you need to have the browser extension installed. A tutorial on how to do that can be found here.
By forking the GitHub Repository, we make a copy of the original repository on our GitHub account to view and/or make changes without affecting the original owner’s repository. You can fork this repository by using the following steps:
There is a noticeable difference between local and deployment. The os function allows CLI to clear the entire previous terminal output before replacing it with the new terminal output. This function was able to clear the entire terminal output in local. However, when deployed to Heroku, the os function only clears 24 lines rather than the entire terminal output, regardless of the terminal window size. This is a known issue. Additionally, the colorama function appears to display in normal colour in the local terminal window, but the same appeared a bit darker and dull in Heroku.
Source | Notes |
---|---|
Markdown Builder | tool to help generate the Markdown files |
Trinket | Penalty Shoot-out game idea |
GitHub | Penalty Shoot-out project |
Econowmics | Penalty game idea |
101Computing | Penalty game tutorial |
StackOverflow | Generate game randomiser |
StackOverflow | Detect player or opponent’s turn |
YouTube | Use Colorama in Python project |
GeeksforGeeks | Use import os to clear terminal output |
Stackademic | Write clear and effective Git Commit messages |
No media was used for this project.