"Pirates of the Python" offers a classic one-player Battleships experience against the computer. Crafting this game was enjoyable and allowed me to explore creative elements in game development.
- This program is a pirate-themed version of the classic Battleship game called "Pirates of the Python.".
- In this game, the user's goal is to strategically choose coordinates and sink the computer's battleships before the computer sinks user's ships. It's a playful twist on the classic Battleship game.
"Pirates of the Python" follows the classic gameplay of the game "Battleship." At the main menu, the user can choose to start the game, display rules, or exit the game. Once the game begins, a set of randomly generated ships will be displayed for the user and the computer. The user will also see a blank board for reference.
During the user's turn, they will choose a row and a column. The grid will be updated to reflect hits ('!') or misses ('X'). The first to sink all the opponent's battleships wins the game. After the game, the user has the option to play again.
Live version of the game can be found here: Pirates of the Python
Additionally, players can personalize their experience by choosing a pirate name. They also have the flexibility to set the grid size between 3 and 8 for added customization.
At the start of the game, players are greeted with the "Pirates of the Python" logo set against a pirate-themed background. Below the logo, a menu offers the following options:
- Display Rules
- Start Game
- Exit Game
Display Rules when user choose 1.
Start Game when user choose 2
Let user choose Grid size for the game, and show the board.
Let user choose column & row and show results on board.
Result a draw, if user uses all attempts.
Result a win, if user hit all computer battleships.
Result a lose, if computer wins.
I might incorporate a scoring system for the player and potentially allow them to manually choose the positions of their battleships.
-
- Random was used to generate the user's ships and computer ships at the beginning of the game.
-
- The entire project was coded using Visual Studio Code.
-
- GitHub was used to store the code online and serves as a source for Heroku.
-
- Heroku was used to deploy the Python Terminal online once it was linked to the Repo.
-
- Draw.io was used to create the flowchart for "Pirates of the Python."
To deploy the final build of the project online, Heroku was used. The deployment process involved the following steps:
- Push the latest code to GitHub.
- Go to Heroku.
- Create a new app.
- Enter the application name and choose Europe for the region.
- Search for the Repo.
- Connect to the relevant repo you want to deploy.
- Go to the settings tab.
- Add buildpacks.
- Select Python and save changes.
- Select Nodejs and save changes.
- Ensure that Heroku/Python is at the top of the list, followed by Heroku/Nodejs.
- Go to the deploy tab.
- Scroll down to Manual Deploy and select deploy branch.
All of the code within this program was tested using Code Institute's PEP8.
I addressed a bug in the user choice function where selecting the same coordinates was mistakenly counted as a new attempt. To resolve this, I implemented an error message and prevented users from choosing the same coordinates again.
There are no unresolved bugs.
This tutorial was instrumental in providing insights into crafting the code for the battleship game. It served as a valuable resource, offering guidance and inspiration throughout the development process.
Grateful to mentor Luke for guidance in mastering Python and game development. Thanks to Code Institute for a supportive learning environment. This experience has profoundly shaped my game creation skills.