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

Adding your Own Python Pygame Zero Games to RetroPie on the Picade

Picade Raspberry Pi powered desktop arcade machine

This is a beginners tutorial guide which explains how to setup RetroPie on the Raspberry Pi Picade Arcade and the Picade console. This allows you to play classic retro arcade games on the Picade. The video then explains how you can add your own "emulator" to emulatorstation used by RetroPie. In this case it's not actually an emulator, but adds the ability to run games creating in Python Pygame and Pygame Zero.

The first thing is do install Retropie which is now available for the Raspberry Pi 4 as well as all the earlier versions. RetroPie can be downloaded directly and installed onto an SD card from RetroPie website download page.

Or an easier way to install is using the official Raspberry Pi Imager from the Raspberry Pi downloads page.

When running Picade for the first time you will be asked to configure your controller. As the Picade X HAT used for the joystick is not available until after installing the drivers then you should connect a keyboard and setup using the keyboard. If you use the same keys as the Picade buttons are mapped to then you will be able to use the joystick and buttons once those drivers are installed. There is no set way to configure the keyboard layout, but I chose the layout in the following image which works well for me.

Picade keyboard layout for RetroPie / emulationstation arcade console

Once that is configured you need configure wifi. This first needs the country set through raspi-config and you can then configure the WiFi through emulationstation settings.

Once the network is setup then you can install the Picade drivers by exiting from emulationstation and running the following on the command line:
curl https://get.pimoroni.com/picadehat | bash

If you also enable ssh from raspi-config then you can upload game files into the appropriate ROM directories. For Linux users then you can often use the standard file manager which often supports sftp (Dolphin in Kubunto and Nautilus in Ubuntu). If you are looking for an alternative then FileZilla works with both Linux, Windows and Mac. It is available from the FileZilla Project website.

If your operating system does not include an ssh client then you can download PuTTY to allow you configure the Picade without using a physical keyboard. Download PuTTY from here.

See the following for links to sources of ROMs. I believe these are all legal downloads, but please check yourself before downloading.

Pygame Zero is installed using
sudo apt install python3-pgzero

The sample source code, including the Pygame Zero EmulationStation theme is provided with the book Beginning Game Programming with Pygame Zero, by Stewart Watkiss, published by Apress. Or you can download the source code directly from Source code for the book Beginning Game Programming with Pygame Zero.

To setup the Pygame Zero theme and add the game run the following commands:



wget https://github.com/Apress/beginning-game-programming-with-pygame-zero/archive/master.zip 

unzip master.zip

cd beginning-game-programming-with-pygame-zero-master

cd Chapter\ 11



cp -r spaceshooter /home/pi

cp pgzero-retro-theme.tgz /home/pi



tar -xvzf pgzero-retro-theme.tgz



sudo cp -r ~/retropietheme/* /etc/emulationstation/themes/carbon/ 

The add the following to /etc/emulationstation/es_systems.cfg before the last </systemlist> entry:



  <system>

    <name>pygame</name>

    <fullname>Pygame / Pygame Zero</fullname>

    <path>/home/pi/RetroPie/roms/pygame</path>

    <extension>.sh</extension>

    <command>%ROM%</command>

    <theme>pygame</theme>

  </system>

Then run the following commands:



cd /home/pi/Retropie/roms/

mkdir pgzero



cd pgzero

add shell filek called spaceshooter.sh with the following contents





cd ~/spaceshooter

pgzrun spaceshooter.py

Then add execultable permission using:



chmod +x spaceshooter.sh

See more about the Space Shooter game in the following video.

You may also want to see Tutorial to getting started with Pygame Zero

Future projects

I'm always working on new projects
To find out about the updates please:
Subscribe to the PenguinTutor YouTube Channel
and
Follow @penguintutor on Twitter

Previous Memory Card Game
Memory Card Game
Next Games for RetroPie
Games for RetroPie