Third party cookies may be stored when visiting this site. Please see the cookie information.

Home Family Days Out Raspberry Pi & Electronics Blog

Stewart's Blog

Stewart Watkiss website to the world ...

(Children, computing, first aid and other ramblings ...)

Tank Game for Pygame Zero and the Raspberry Pi Pico Display Pack

February 27th, 2021

This is an introduction to a tank game I created. It’s an artillary style pass and play game. It is created as a demonstration of creating vector graphics in Pygame Zero and of porting / creating a game on the Raspberry Pi Pico with the Pimoroni Display Pack.

Pygame Zero Game

The initial version was created in Python Pygame Zero as part of the book Beginning Game Programming with Pygame Zero.

Tank game created in Pygame Zero on a Raspberry Pi

More details of the original game are in the book Beginning Game Programming with Pygame Zero

Installing / Running the Pygame Zero game

The Pygame zero version is in the folder pygamezero. All the files need to be in a single folder and the game launched from that folder.

You need either the Mu Editor installed or Python with Pygame Zero installed. This is included as standard on the Raspberry Pi.

If you have the Mu editor installed then you can load the file tankgame.py into the Mu editor, ensure you are in Pygame Zero mode and then choose run.

To run using the command line and pygame zero change to the game’s pygame zero directory and then run

pgzrun tankgame.py

Playing the Pygame Zero Version

Play starts with player 1. The angle of the current tank is adjusted using the up and down arrow. The power is adjusted using the left and right buttons and then press the space bar to fire a shell towards the enemy.

If you score a hit then you win, otherwise the game passes to the next player.

Raspberry Pi Pico with Pimoroni Display Pack

This is designed to play on a Raspberry Pi Pico with the Pimoroni Display Pack.

Tank Game on Raspberry Pi Pico with Pimoroni Display Pack

Installing / Running the Pico Display version

Before you can run the game you need the Pimoroni version of MicroPython. For details on how to install see the Pimoroni getting started with Pico guide.

The Raspberry Pi Pico program is in the directory picodisplay. You need to copy all of the files onto the Pico. The easiest way to do this is using the Thonny editor. Copy and paste each file into a new page in the editor and save that as the same file on the Pico.

Playing the Raspberry Pi Pico version

The game is a pass and play game starting with player 1. Press the B button to select between Angle and Power adjustment. The appropriate mode will be displayed on the screen. Press the X and Y buttons to adjust the angle or power as appropriate. Press the A button to fire a shell.

If you score a hit then you win, otherwise the game passes to the next player.

More Details

For more details about the game see Guide to porting the tank game from Python Pygame Zero to the Raspberry Pi Pico with Display Pack.

Hanbury Circular Walk

February 13th, 2021

This is a way marked route by Worcestershire County Council. Starting at Gateway Park near Droitwich Spa Marina (approx. postcode WR9 7DU). it goes along the Worcestershire and Birmingham Canal, and then across fields passing Hanbury Hall (National Trust).

Distance: 7 miles (including walk around the outside of Hanbury Church).

Map Hanbury Circular Walk
Click the map for a larger version

Worcestershire and Birmingham Canal at Hanbury Gateway Park

Hanbury Hall, National Trust house in Worcestershire

The route is also available through the Ordnance Survey Online OS Maps and as a GPX file for handheld sat nav systems.

Details of the route : Hanbury Circular Walk (Worcestershire County Council).

Redditch Dinosaur Walk

February 6th, 2021

This is a walk starting at Morton Stanley Park walking around local roads in the Redditch area. If you map your route using a GPS then it will be trace the image of a dinosaur.

Distance: 6.2 miles

Map of Redditch dinosaur walk - click for larger version
Click map for larger version

Redditch Dinosaur Walk

The route is also available through the Ordnance Survey Online OS Maps and as a GPX file for handheld sat nav systems.

This route is based on an existing route, unfortunately I don’t know the original creator to give appropriate credit.

Morton Stanley Park to Elcock’s Brook and Ham Green, Walk in Redditch

January 23rd, 2021

A walk through local paths including parts of the Monarch’s way. This walk has some challenges in terms of difficult stiles and can get very muddy. In some places I had to take an alternative route due to flooding of the path.

Distance: 5.2 miles
Terrain: Footpaths. Includes difficult terrain, stiles and may be very muddy.

Map of the Morton Stanley Park to Elcock’s Brook and Ham Green, Walk in Redditch
Click map for a larger version

Photo on Morton Stanley Park to Elcock’s Brook and Ham Green, Walk in Redditch

The route is also available through the Ordnance Survey Online OS Maps and as a GPX file for handheld sat nav systems.

Raspberry Pi Pico on YouTube #Shorts

January 23rd, 2021

I’ve now created my first YouTube #Shorts.

It’s a quick demonstration of the Raspberry Pi Pico switching a large load through a darlington Transistor.

I’ve also created a standard video on the Raspberry Pi Pico and how to get started using MicroPython here:

This video is based around the Transistor switch and darlington driver video but I had already published that video before the Raspberry Pi Pico came out.

What are YouTube #Shorts

YouTube shorts are very short videos, created in portrait mode designed to be very short. Does that sound familiar? It’s essentially YouTube’s version of TikTok.
These are often raw footage videos. Some people may just want to create shorts, but in my case I think they may be useful to show simple clips of my projects to be followed up by full Videos or write-ups on my website.

It will be interesting to see how YouTube develops these further.

More YouTube Shorts

I’ve created a second short as a preview of my Raspberry Pi Pico Voltmeter project:

Raspberry Pi Pico – A microcontroller from Raspberry Pi

January 22nd, 2021

There’s a new microcontroller available but this one is from an unexpected manufacturer – Raspberry Pi!

Raspberry Pi well known for their single board computers has now branched out into a micro-controller. This has been done in partnership with other micro-controller supplies such as Arduino, who are expected to release a board based around the same micro-controller integrated circuit later this year.

The board is known as a Raspberry Pi Pico and is based around their own custom microcontroller IC known as the RP2040. The microcontroller has 256kB of memory and 2MB of flash memory which doesn’t sound a lot, but is quite reasonable for a low cost microcontroller.

Raspberry Pi Pico

The Pico can run code created in C++ or in MicroPython. The inclusion of MicroPython as a mainstream language is a game changer which is going to make microcontrollers more accessible to Python programmers.

The video goes through some details of the Pico and gives a basic tutorial on how to get up and running by installing the MicroPython interpreter onto the Pico and getting your first program up and running.

I plan to add more videos on the Raspberry Pi Pico in future so please subscribe to my YouTube channel to get notified of future videos.

Webheath to Banks’s Green Walk, Redditch

January 16th, 2021

This is a walk starting at St. Philip’s Church in Webheath Redditch. It goes to Bank’s green by using a combination of the Monarch’s Way and country lanes. Approx 60% of this is on roads. The route is based on one that I have followed as part of the Scout’s Shirehike.

Distance: 3.8 miles

Map of walk Webheath to Bank's Green - click for larger version
Click map for larger version

Fields near Bank's Green on walk

Ford on Webheath to Bank's Green Walk

The route is also available through the Ordnance Survey Online OS Maps and as a GPX file for handheld sat nav systems.

Monarch’s Way

The Monarch’s Way is a 615 mile long-distance footpath route. It is based around the escape route that was taken by King Charles II in 1651 after defeat at the battle of Worcester. The route is well maintained and signposted.

Batchley and Enfield Woodland Walk, Redditch

January 10th, 2021

This is walk around the Batchley and Enfield areas of Redditch. It goes through 3 different wood areas, the Memorial Garden and 2 local parks. It also includes the site of the former Enfield factory and the railway.

Distance: 4.5 miles
Terrain: Woodland and tarmac paths. Includes some stairs (alternate route available).

Map of the Batchley and Enfield Woodland Walk Redditch
Click map for a larger version

Site of former Enfield cycles factory in Redditch (Batchley and Enfield Woodland Walk)

The route is also available through the Ordnance Survey Online OS Maps and as a GPX file for handheld sat nav systems.

SnowPi RGB Christmas Game for Raspberry Pi

December 21st, 2020

My Christmas maker project this year is a game based around the SnowPi RGB. This is a PCB with addressable RGB LEDs (also known as NeoPixels).

The game is created in Python pygame zero. In the game you have to press an appropriate key (or button on the joypad) at the right time. It’s a simple skill based reaction game with the need to press the correct button at the right time. The USB joypad is handled using qjoypad.

See the SnowPi RGB Game page for more details and to download the source code.

Raspberry Pi controlled Christmas Lighting including NeoPixels and RGB Matrix LED display

December 3rd, 2020

This video explains about the Christmas lighting display I have at my house and how it’s controlled using 3 Raspberry Pi computers. Two of these are automated, but one does require manual intervention to turn it on and off.

There are outdoor Christmas lights including Christmas Tree lights and light-up animals using LED lighting. These are run off mains electricity so needed a safe method to turn them on and off. I achieved this using the Energenie remote control sockets with a Pi-mote. See more about this in my Raspberry Pi home automation project

Christmas tree with decorations and Raspberry Pi controlled lights

There are also NeoPixels / addressable RGB LEDs which are controlled using my NeoPixel GUI application.
See video of the Raspberry Pi controlled RGB PixelStrip / NeoPixel LEDs and the Raspberry Pi NeoPixel LED GUI application.

Finally there is an RGB matrix LED display which I have programmed to play animations which are stored as a series of png files.
See more details on the video Raspberry Pi RGB LED Matrix display.

The animation shown is an animated advent calendar for the 1st of December. This is created manually by creating the individual frames in LibreOffice draw and then exporting them as individual PNG files. I also plan to create some more animations using Blender 2.9 using the 2D animation mode.
I’ve also created a video tutorial on 2D animation in Blender 2.8 and 2.9.

These are just some of the projects I’ve done using a Raspberry Pi.
You can find more on the PenguinTutor project page.

Twitter Status - follow stewartwatkiss


UK days out, children and holiday information is also available on the Days Out Diary web site
Linux, LPI and the Quiz / Test Program posts are also available on the Penguin Tutor website
First Aid Information, first aid games and first aid practice test / quiz entries are also available on the First Aid Quiz Web site