Code the Classics - Volume II - Pi 400 and 500 Guide



A few months ago I posted on how to get the code from Code the Classics - Volume II up and running quickly on macOS.

Since the book was published by Raspberry Pi Press, it thought let me do the same the Pi 400 and 500.

I’ve put the below steps together to help anyone wanting to get the games up and running quickly.

If you just want to play the games, not code review or tinker with the code, I have added how to play the games standalone at the end of the post.

On the Pi 400 I ran the code on Raspberry Pi OS (32-bit) bookworm but found the games very sluggish, so would recommend upgrading to the Raspberry Pi OS (64-bit) bookworm.

Below is a summary on how to upgrade to Raspberry Pi OS (64-bit) for full steps go here.

      - Download the 64-bit Raspberry Pi OS image 
      - Flash the image to an SD card using the Raspberry Pi Imager
      - Insert the SD card into your Pi 400
      - Boot up your Pi 400 and complete the initial setup

I have tested the below on the Pi 400 and 500.

Let's make sure we have everything in place.

The below is all run via Terminal, let’s make sure Raspberry Pi OS is up to date.
              
$ sudo apt update    

            $ sudo apt full-upgrade 

Check Python 3 version, should be 3.11.2 or higher

            $ python3 —version

Check Pygame version, should be 2.1.2 or higher

            $ pip3 show pygame

Install git, this will be used to "copy" / clone the games code to the Pi.

              $ sudo apt install git-all

The above Python 3 and Pygame versions are the currently installed on Raspberry PI OS (as of this writing).

Installing a Joystick Keyboard Mapper (Optional).

I normally do this as I prefer playing games via a controller and map the keys, but as mentioned this is optional.

Note: The games do have a Joystick option.

The Joystick Keyboard Mapper I use is Qjoypad

             $ sudo apt-get install qjoypad

Playing the Games

Since we just want to play the games for now, I will clone the "Games" repository under the Downloads directory

The below is all run via Terminal

Change to the Downloads dirctory (I am assuming you are in the User directory)

               $ cd Downloads 

Clone the "Games" from the books GitHub repository

                $ git clone https://github.com/raspberrypipress/Code-the-Classics-Vol2

Once the clone has completed move into the games direcorty

                $ cd Code-the-Classics-Vol2

You can now list the games

                   $ ls

You should see the below listing

                README.md beatstreets eggzy leadingedge avenger cover kinetix

Let's play Beat Streets (Double Dragon Inspired)

                $ cd beatstreets
                $ pgzrun beatstreets.py

Editing and Review the Code

The book recommends using Thonny or PyCharm CE to review and edit the code.

I tried running the game code through Thonny but kept running into errors, after researching the issue it looks like there is a bug in Thonny (that is what I found).

As much as I like PyCharm, I think it's a "little heavy" for the Pi 400.

By default on the Raspberry Pi OS (64-bit) build Geany is installed.

It ran the code without a hitch, so I would recommend using it if you don't have another preferred code editor.

Installing the games just to play

To install the games in Code The Classics and Code The Classics - Volume II follow the below steps

              - Select the Raspberry Icon on the taskbar
              - Select Preferences
              - Select Recommend Software
              - Under the Recommend Software Application, find the Games option and                     tick both Code the Classics and Code the Classics 2 
              - Select Apply

This will go ahead and install the games, you will the find the games under Games in the main menu.  





Popular posts from this blog

Code the Classics - Volume II - macOS Guide

Behind the Pixels - Week 20

Behind the Pixels - Week 21