Buy the book
Mu Editor
PyGame Zero
Python

CODE IN PYTHON

3 Steps away from starting an adventure...

With the book "Code in Python – let’s create an adventure game", each of you - a student, a teacher, a parent will be able to create an adventure game on their own. By writing subsequent pieces of code, we will learn Python. In the book we place great emphasis on interdisciplinarity. We show that creating an adventure game is not only computer science, but also native language – in script development, mathematics – in all necessary calculations, art – in character and scenography designing, music – in creating sound effects and music. Depending on their talents, everyone will be able to use them in the corresponding area. To start programming the game we need an editor. We chose a very simple and friendly working environment - Mu Editor. It is created for novice programmers - like you. Just install the editor and we are ready to start!

INSTALLATION AND CONFIGURATION

Press the button and download the application that installs the Mu editor and the entire development environment needed to create the adventure game. Download the file appropriate for your operating system (Windows, OSX, Linux) and then run the installation program. Below is a detailed installation guide for the system of your choice. After installation, run the Mu editor and then configure it according to the instructions below.

If you have gone through the installation and started the editor, it's time for the next step

EDITOR INSTALLATION INSTRUCTIONS

Windows Installation Guide

Step 1 Download Mu Installer

Download the appropriate installer for your operating system: 32-bit or 64-bit. The buttons to download the corresponding version of the editor are located above. To find out which installer is right for your system, right-click on 'This Computer' and select the properties option. Find the operating system type in the System Type tab.

Step 2 - Start the installer

Find the Mu editor installation program you downloaded and run it by double-clicking on the installer icon.

Step 3 - License Agreement

Read the license, and then if you want to continue the installation click the 'Agree' button .

Step 4 - Select users

Choose whether you want to install the Mu editor for all users or just for yourself and click 'Next'. Please note that if your user account does not have administrative rights, this step may not appear during the installation process. In that case, the installer can only work if you select 'Install just for me'.

Step 5 - Choose where you want to install the editor

We suggest that you do not change the automatically proposed path. This will make it easier for you to complete the setup.

Step 6 - Installation

Wait for the Mu editor to install on your computer.

Step 7 - Completion of installation

The installation is complete, click the 'Finish' button to close the installer. You can start the Mu editor for example by clicking icon on the Start menu.

Mac OSX Installation Guide

Step 1 Download Mu Installer

Download the Mac OSX installation program by clicking the download button above.

Step 2 – Open the installation program

Open the Downloads folder – click ‘Go’ and then ‘Downloads’ in the Finder menu.

Double-click the Mu installer disk image (.dmg file). When you open the installer, you will be asked to accept the software license agreement, and then your computer will check if the package is not damaged (it may take a few minutes).

Step 3 - Mu Installation

Click on the ‘mu-editor’ icon, hold it down, and drag it to the Applications folder.

Step 4 – Installation

The Mu editor will install in the Applications folder.

Step 5 - Start Mu

Open the Applications folder – click 'Go' and then 'Applications’ in the 'Finder' menu. Press CTRL and click on the Mu icon. A dialog box appears where you can check if you want to open Mu. Click on 'Open':

Linux Installation Guide

Step 1 – Start the installation process by entering the following command::

pip3 -V

This way you'll check if you have pip for Python3 installed. If you don't have one, install the package that's right for your distribution, i.e. for Debian/Ubuntu/Mint systems this could be a package called python3-pip.

Step 2 - Install the editor by typing the following command::

sudo -H pip3 install mu-editor

Step 3 – Check if the editor is installed by typing the following command::

/usr/local/bin/mu-editor


Step 4 - Add an icon to your desktop. Here's an example for Mint:


EDITOR CONFIGURATION

When you start the Mu editor, press the ‘Mode’ key in the upper-left corner of the editor's main menu. Then, in the window that appears, select ‘Pygame Zero’ and press the ‘OK’ key. The editor will switch to ‘Pygame Zero’ mode. Our environment is ready to go!

GRAPHICS AND SOUND

Press the 'Download Files' key. This way you'll download one zipped file containing all the resources you need for the game: images, fonts, sounds, and music. After unpacking the file, a directory tree will be created on the disk containing all the aforementioned graphic assets (images and fonts) and sound (music and sound special effects).

Download files

When you have imported files into the editor, it's time for the last step

INSTRUCTIONS FOR IMPORTING

FILES INTO THE EDITOR

To copy all downloaded files to the relevant directories required by Pygame Zero, unzip the downloaded 'code-in-python' directory and copy all the directories in the directory. Next, we need to find the mu_code directory that we installed with the MU editor, delete all the directories in it, and paste those just copied. Default directory location mu_code installed with editor

for Windows: Users/username/mu_code, for MAC OSX: /Users/username/mu_code, for Linux: /home/username/mu_code

ADVENTURE GAME CODE

If you want to play the entire adventure game right away, copy the game code from Chapter R10 to the clipboard. Press the "copy code to clipboard" key, go to the "Mu Editor" window, and paste the code from the clipboard (ctrl+V or Cmd+V). If you have our book "Code in Python", we recommend copying the code chapter by chapter, starting with Chapter R02 and ending with R10. By learning the code associated with the next chapters, we gradually develop our skills while building an adventure game.

R01
Where to start
R02
Images and introduction to variables
R03
Object-oriented programming
R04
Game Rules - Algorithms
R05
Rooms plan – lists, dictionaries
R06
Character animation, ways to change the images
R07
Create a scenario
R08
Changing scenes – let's move between rooms
R09
Check and update the game status
R10
Music and sounds
Download Appendix A

If you'd like to know more about GitHub download Appendix A

Game code available on GitHub:

R01
Where to start
R02
Images and introduction to variables
R03
Object-oriented programming
R04
Game Rules - Algorithms
R05
Rooms plan – lists, dictionaries
R06
Character animation, ways to change the images
R07
Create a scenario
R08
Changing scenes – let's move between rooms
R09
Check and update the game status
R10
Music and sounds