Play Battleships on your SenseHAT with your Raspberry Pi

Dan Aldred has posted the code for a SenseHAT-based version of the classic game Battleships. Here’s how he describes it:

The program creates a random layout of boats, ammo and water. Use the joystick to select a location and then press Enter to fire a Torpedo.

If you miss you will here a splash of water, if you hit then you will hear the explosion. Else you may find an ammo dump. Each square is then coloured, blue for water, red for a ship and yellow for ammo. You will be updated n the number of ships left to destroy.

When you have used all your Torpedoes up or you have destroyed all the ships, then game ends and you are updated with your score. You can select to play again and a new random layout is created, or leave the game.

Great idea from Dan! You can download the Python 3 code here and see a video of it in action below:

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.