Raspberry Pi

Updating the Raspberry Pi Vbox Image

So one of the things I like to do is test out a lot of my python gaming code, (as far as for the coding and syntax) on my Oracle Virtualbox image of my Raspberry Pi.  Another great thing about building games on the Raspberry Pi, is a built in module called Pygame.  Well, that doesn’t exist on the Raspberry Pi image and it really limits what we can do when it comes to the VNC build we play on the Oracle Virtualbox, (that’s a mouthful… :))

Get Outside Access

The first step is to first get out to all the libraries, as the ports the image is a bit locked down.  At the top, click on Devices, Network, Network Settings.  Add a check mark for “Cable Connected” and then click on the “Port Forwarding” settings.  Update the settings to reflect what I have for the open ports, (remember, this is Oracle Virtualbox… :))

vbox_rpi1

Once you’ve updated the Host and Guest Port, click OK.

Installing Pygame

As I want to stay with Python 3 as much as possible, we’re going to install it with our Vbox image with the Python 3 build.  Let’s start by installing:

sudo apt-get install mercurial

Choose “Y” for both questions and proceed with the installation.  There are a lot of files here, (over 500) so it will take just a few minutes to install everything.  Now, we need to run the clone step:

sudo hg clone https://bitbucket.org/pygame/pygame

Once this complete, which is just a matter of seconds, again, choosing “Y” for the questions, we need to build the dependencies after we download those:

sudo apt-get build-dep pygame
sudo apt-get install python3-dev
sudo apt-get install python3-numpy
cd pygame
sudo python3 config.py

You shouldn’t run into any failures at this step, as I didn’t with my own image.  If you do, you can go back to the first step and instead run:

sudo apt-get update

If all is successful at this point, then it’s time to build and install:

sudo python3 setup.py build
sudo python3 setup.py install

Alsa Sound Libraries

Now we need the Alsa Sound Library that isn’t in this image.  These are called by the Pygame module and come by default on Raspberry Pi, but yep, not here! You can check first to verify that they aren’t there, (if you’re curious…):

apt-cache policy alsa-base libasound2 alsa-tools

Now run the install with the following command:

sudo apt-get install alsa-utils
sudo apt-get install alsamixer

You’ll now see the ALSA sounds libraries if you run the check command again.

Now you’re ready to code Pygame games on your Virtualbox image of the Raspberry Pi! 🙂

Kellyn

http://about.me/dbakevlar