100% found this document useful (2 votes)
116 views55 pages

Coding Games in Python 1st Edition Carol Vorderman all chapter instant download

Vorderman

Uploaded by

foworasefrid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
116 views55 pages

Coding Games in Python 1st Edition Carol Vorderman all chapter instant download

Vorderman

Uploaded by

foworasefrid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Experience Seamless Full Ebook Downloads for Every Genre at textbookfull.

com

Coding Games in Python 1st Edition Carol Vorderman

https://textbookfull.com/product/coding-games-in-python-1st-
edition-carol-vorderman/

OR CLICK BUTTON

DOWNLOAD NOW

Explore and download more ebook at https://textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Computer Coding for Kids A Unique Step by Step Visual


Guide from Binary Code to Building Games 1st Edition Carol
Vorderman
https://textbookfull.com/product/computer-coding-for-kids-a-unique-
step-by-step-visual-guide-from-binary-code-to-building-games-1st-
edition-carol-vorderman/
textboxfull.com

How to Be Good at Maths Carol Vorderman

https://textbookfull.com/product/how-to-be-good-at-maths-carol-
vorderman/

textboxfull.com

Coding for Kids Python Learn to Code with 50 Awesome Games


and Activities 2019th Edition Adrienne B. Tacke

https://textbookfull.com/product/coding-for-kids-python-learn-to-code-
with-50-awesome-games-and-activities-2019th-edition-adrienne-b-tacke/

textboxfull.com

Help Your Kids with Music A Unique Step by Step Visual


Guide Carol Vorderman

https://textbookfull.com/product/help-your-kids-with-music-a-unique-
step-by-step-visual-guide-carol-vorderman/

textboxfull.com
Help Your Kids with Maths A Unique Step by Step Visual
Guide Carol Vorderman

https://textbookfull.com/product/help-your-kids-with-maths-a-unique-
step-by-step-visual-guide-carol-vorderman/

textboxfull.com

Help Your Kids with English A Unique Step by Step Visual


Guide Carol Vorderman

https://textbookfull.com/product/help-your-kids-with-english-a-unique-
step-by-step-visual-guide-carol-vorderman/

textboxfull.com

Coding Projects in Scratch A Step by Step Visual Guide to


Coding Your Own Animations Games Simulations and More 1st
Edition Dk
https://textbookfull.com/product/coding-projects-in-scratch-a-step-by-
step-visual-guide-to-coding-your-own-animations-games-simulations-and-
more-1st-edition-dk/
textboxfull.com

The Python Book: The Ultimate Guide to Coding with Python


Imagine Publishing

https://textbookfull.com/product/the-python-book-the-ultimate-guide-
to-coding-with-python-imagine-publishing/

textboxfull.com

Competitive Programming in Python: 128 Algorithms to


Develop your Coding Skills 1st Edition Christoph Dürr

https://textbookfull.com/product/competitive-programming-in-
python-128-algorithms-to-develop-your-coding-skills-1st-edition-
christoph-durr/
textboxfull.com
codinG
Games
PYTHON
R

IN
codinG
Games
PYTHON
R

IN
DK UK
Project editor Ben Ffrancon Davies
Senior art editor Sunita Gahir
Consultant editor Craig Steele
Jacket design development manager Sophia MTT
Jacket editor Claire Gell
Producer, pre-production Gillian Reid
Senior Producer Alex Bell
US editors Jill Hamilton, Kayla Dugger
Managing editor Lisa Gillespie
Managing art editor Owen Peyton Jones
Publisher Andrew Macintyre
Associate publishing director Liz Wheeler
Art director Karen Self
Design director Phil Ormerod
Publishing director Jonathan Metcalf

DK INDIA
Senior editor Bharti Bedi
Project art editor Sanjay Chauhan
Editor Tina Jindal
Assistant art editors Rabia Ahmad,
Simar Dhamija, Sonakshi Singh
Jacket designer Juhi Sheth
Jackets editorial coordinator Priyanka Sharma
Managing jackets editor Saloni Singh
DTP designer Sachin Gupta
Senior DTP designer Harish Aggarwal
Senior managing editor Rohan Sinha
Managing art editor Sudakshina Basu
Pre-production manager Balwant Singh
First American Edition, 2018
Published in the United States by DK Publishing
345 Hudson Street, New York, New York 10014

Copyright © 2018 Dorling Kindersley Limited


DK, a Division of Penguin Random House LLC
18 19 20 21 22 10 9 8 7 6 5 4 3 2 1
001–309872–July/2018
All rights reserved.
Without limiting the rights under the copyright reserved above, no part
of this publication may be reproduced, stored in or introduced into a
retrieval system, or transmitted, in any form, or by any means (electronic,
mechanical, photocopying, recording, or otherwise), without the prior
written permission of the copyright owner.
Published in Great Britain by Dorling Kindersley Limited

A catalog record for this book


is available from the Library of Congress.
ISBN: 978-1-4654-7361-5
Printed in China

A WORLD OF IDEAS:
SEE ALL THERE IS TO KNOW
www.dk.com
CAROL VORDERMAN MBE is one of Britain’s best-loved TV presenters and is
renowned for her mathematical skills. She has hosted numerous TV shows on
science and technology, from Tomorrow’s World to How 2, and was co-host of
Channel 4’s Countdown for 26 years. A Cambridge University engineering
graduate, she has a passion for communicating science and technology and
is particularly interested in coding.

CRAIG STEELE is a specialist in computing science education who helps people


develop digital skills in a fun and creative environment. He is a founder of
CoderDojo in Scotland, which runs free coding clubs for young people. Craig
has run digital workshops with the Raspberry Pi Foundation, Glasgow Science
Centre, Glasgow School of Art, BAFTA, and the BBC micro:bit project. Craig’s first
computer was a ZX Spectrum.

DR. CLAIRE QUIGLEY studied computing science at Glasgow University,


where she obtained BSc and PhD degrees. She has worked in the Computer
Laboratory at Cambridge University and Glasgow Science Centre, and is
currently working on a project to develop a music and technology resource
for primary schools in Edinburgh. She is a mentor at CoderDojo Scotland.

DANIEL McCAFFERTY holds a degree in computer science from the University


of Strathclyde. He has worked as a software engineer for companies big and
small in industries from banking to broadcasting. Daniel lives in Glasgow with
his wife and two children, and when not teaching young people to code, he
enjoys bicycling and spending time with his family.

DR. MARTIN GOODFELLOW is a teaching associate in the Computer and


Information Sciences department at the University of Strathclyde. He has
also developed educational computer science content and workshops for
other organizations in the UK and China, including CoderDojo Scotland,
Glasgow Life, Codemao, and the BBC. He is currently the Scottish
Ambassador for National Coding Week.
Contents
8 FOREWORD COIN COLLECTOR
GETTING STARTED 60 How to build Coin Collector
Score: 0

12 What is Python?
14 Gaming in Python
16 Installing Python
18 Installing Pygame Zero
20 Using IDLE
22 Your first program

FOLLOW THE NUMBERS


LEARNING THE BASICS 70 How to build Follow the Numbers

28 Creating variables
32 Making decisions
36 Playing with loops
40 Functions
44 Fixing bugs

SHOOT THE FRUIT RED ALERT


50 How to build Shoot the Fruit 82 How to build Red Alert
BIG QUIZ HAPPY GARDEN
100 How to build Big Quiz 156 How to build Happy Garden
Garden happy for: 16 seconds

What is the
capital of France? 7
London Paris
Berlin Tokyo

BALLOON FLIGHT SLEEPING DRAGONS


118 How to build Balloon Flight 178 How to build Sleeping Dragons
Score: 0

6 2

DANCE CHALLENGE REFERENCE


138 How to build Dance Challenge 198 Project reference
Score: 0
220 Glossary
222 Index
224 Acknowledgments
Foreword

Computer programmers are the unsung heroes of the modern world. From smartphones
to laptops, traffic systems to bank cards, their hard work touches almost every aspect
of our lives. Behind each technological advance is a team of creative coders.

Over the past 30 years, computer games have become one of the most exciting and
popular areas of the entertainment industry to work in. Becoming a game programmer
takes creative flair to help create the story, graphics, music, and characters you need
for your games, and the technical know-how to bring them to life. Who knows? This
book may be the very first step on your journey from gamer to game maker.

Learning to code isn’t just for people who want to be professional programmers,
though. Coding skills are useful in lots of different jobs that may seem to have nothing
to do with computers at first. Programming expertise is essential to subject areas as
diverse as science, business, art, and music.

This book uses a programming language called Python®, a fairly simple text-based
language, and is perfect for beginners, or as a step up from Scratch™. However,
unlike Scratch, it was not created especially to teach coding. Python is as popular with
budding coders as it is with professionals, and is one of the most widely used
professional programming languages in the world. It pops up in banking, medicine,
animation, and even space exploration.

The best way to learn any new language is to get immersed in it, and programming
languages are no different. Building your own computer games is a fun way to combine
theory and practice. If you’re a brand-new coder, start off with the basics at the
beginning of this book before moving on to the more complex games as the book
progresses. By following the step-by-step guides, you’ll find out how professional
coders think when they’re building a computer game. Follow those steps carefully and
you’ll have your own games up and running in no time. Then, if you really want to push
yourself, you can try tweaking the code to make your games unique.

Everybody, whether a beginner or a pro, makes mistakes. Nothing frustrates a coder


more than the bugs that manage to creep into their programs. If something goes
wrong in one of your games, go back over your code and check it all carefully. There
are hints and tips throughout the book that will help you do this. Most importantly,
don’t get disheartened—finding and fixing errors in your code is all part of being a
programmer. The more practice you get, the fewer bugs your code will contain, and
the quicker you’ll catch the little ones that still appear.

Most importantly, have fun! Once you’ve completed the games, you can show them off
to your friends and family—they’ll be amazed by what you’ve managed to make. This
book is packed with games to suit every audience, and we hope you enjoy building and
playing them as much as we enjoyed creating them for you.

Have fun coding!


Getting
started
12 G E T T I N G S TA R T E D

What is Python? Python is great!


I can take
Computers need step-by-step instructions it anywhere.
to perform different tasks. A set of instructions,
or code, can be written in different
programming languages. Python is one of
the most popular programming languages.

Why Python? △ Portable


Python is a powerful programming language that The same Python code will work on PCs,
you can use to code simple programs quickly. It’s Macs, Linux machines, and Raspberry Pi
computers. The programs act in a similar
not too hard to learn and it’s great for building way on each platform, so games created
apps and games. Here are some of the reasons with Python can be played on lots of
why Python is such a great tool for programmers. machines all around the world.

1+1=2
◁ Diverse applications
Python is used to build
△ Easy to understand systems and tools for lots of
Unlike some other programming languages, Python interesting tasks in different
doesn’t use complicated symbols. You type the industries, such as banking,
code using a mixture of English words, characters, and healthcare, the space industry,
numbers, so it’s easy to read and write—just like a book. education, and many others.

Better get started!

△ Packed with tools △ Lots of help


Python comes with everything you need to start Python’s website is packed with support
coding right away, so programmers say it comes materials to help you learn how to use it. It has a
with “batteries included.” It contains lots of guide to getting started, several pieces of sample
prewritten code, called the Standard Library, code, and a reference section to help you
that you can use in your programs. understand the code.
W H AT I S P Y T H O N ? 13
From Scratch to Python
Scratch is a visual language, whereas Python is text
based. If you’ve used Scratch, you will recognize some
of the features and ideas in Python. The two languages
might look different, but lots of the elements that are
used in Scratch are also used in Python.

print("Hello World!")
when clicked This block displays
the message in a Type your
say Hello World! speech bubble. message here.

Hello World!
The message appears
on the screen like this.

Hello World!

△ Print in Python
△ Print in Scratch In Python, the “print” command displays
In Scratch, the “say” block is used to a message on the screen.
display a message on the screen. This command
is executed if
the condition
after if is True. if a == 2:
if a = 2 then This message is
print("Hello!") displayed if the
This message is else: answer is False.
say Hello!
displayed if the
answer is True. print("Goodbye!")
else
This command
say Goodbye!
is executed if the
This is the end of the condition after
“if-then-else” block. if is False.

Goodbye!
Hello! ? Goodbye!

△ Set a condition with Scratch △ Set a condition with Python


The “if-then-else” block lets you choose which part of In Python, “if-then-else” commands work
the script to run depending on whether the condition exactly the same way, but they don’t use
is True or False. the word “then.”
14 G E T T I N G S TA R T E D

Gaming in Python
Video games are computer programs that
contain a bunch of instructions. Python can
be used to build lots of different types of
games. With Python, there’s something for
every gamer!

Types of games
There are lots of different categories, or
genres, of computer games. These range
from simple one-button games to more ▷ One button
complex strategy ones. Which genre would With Python, you can build fun,
you like to create first? action-packed games that only
need one button to be played.
These games are so addictive,
you’ll want to play them over
and over again.

◁ Puzzles
Puzzles are a great
way to exercise your
brain or test someone’s
general knowledge.
They come in all shapes
and sizes, from jigsaw △ Platform
puzzles to word and Platform games, such as racing games, create
number games. the illusion of speed by making the background
scroll past the player’s viewpoint. The gameplay
generally involves moving around obstacles or
jumping over them.

◁ Strategy
A strategy game is all
△ Multiplayer about decisions. You
Some games you play by yourself, but others let you need to plan ahead
compete against other players. You can use Python to and make the right
build multiplayer games and challenge your friends. choices to win.
GAMING IN PYTHON 15
Python modules EXPERT TIPS
Python has bundles of code called “modules” Downloading modules
that help you complete common coding
tasks. You can use these modules by Python comes with several built-in modules
for developing games, such as Pyglet. But
importing them into your programs.
some other modules, like Pygame, have to
Here are some Python modules that you be downloaded separately.
might find useful.

▽ Pygame
Pygame is designed for writing games in Python.
With this module, you can easily add and control
game characters, update scores and timers, use ◁ Pygame Zero
special animations and graphics, and use gamepads
Pygame Zero is a great module for
and joysticks with your games. It is not a built-in
beginner game programmers. It’s a
Python module, so it needs to be installed separately.
simplified version of Pygame, which makes
it even easier to get started by hiding some
of Pygame’s more complicated features. It
comes with several tools that are useful for
beginners, but it’s also powerful enough
to build some impressive games.

▷ Random
This module can pick a random
number or shuffle a list into a
random order. It is great for
▷ Math adding an element of chance
to a game. Use it when you
Math is a standard Python
want to simulate rolling dice
module that can be used to
or when choosing a random
perform simple calculations
enemy for the player to face.
in games. However, you might
need to use other modules for
trickier calculations.

◁ Tkinter
This tool is used to build
◁ Time simple graphics in games
This module provides tools to to create Graphical
work with time and dates in User Interfaces (GUIs,
a program. For example, you pronounced “goo-eys”)
might need to calculate how that let users interact
many seconds have passed with, and control,
since a game started. Python programs.
16 G E T T I N G S TA R T E D

Installing Python IDLE


LINGO

The games in this book use Python 3. It’s When you install Python 3, you will
free, and you can download it from the also get another free program called
Python website. Follow the instructions IDLE (short for Integrated Development
Environment). Designed for
that match your computer. Never install beginners, IDLE includes a basic
any program unless you have the computer text editor that allows you to write
owner’s permission. and edit Python code.

Z Z Z
Installing Python on Windows
First you need to find out if your computer uses the
32-bit or 64-bit version of Windows. Go to the Start
menu, then Computer, Properties, and choose
System if the option appears.

1 Download Python
Go to www.python.org and click on Downloads. Click 2 Install Python
Open the installer file, then click Custom
on the latest version of Python for Windows. It should Installation, then Next until you get to Advanced
start with the number 3. Select executable installer Options. Leave the checked boxes as they are, but
from the different installer options that appear. make sure “Install for all users” and “Add Python to
environment variables” are also checked. Then
click Install and Next at each prompt.
The version number might not be
exactly the same as this one—just
make sure it has 3 at the beginning. Click the
installer.

• Python 3.6.2 - 2017-05-15


• Windows x86 executable installer
• Windows x86-64 executable installer
3 Start IDLE
Once the installation process is complete,
open IDLE by searching for it or going to
Use this installer if Use this installer if the Start menu, choosing All Apps, then
you have a 32-bit you have a 64-bit selecting IDLE. A window like the one
version of Windows. version of Windows. below should appear.

Python 3.6.2 Shell


IDLE File Edit Shell Debug Window Help
Python 3.6.2 (v3.6.2:5fd3365926, Aug 15 2017, 00:45:10) [MSC v.1900 32 bit
(Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>
I N S TA L L I N G P Y T H O N 17
Installing Python on a Mac EXPERT TIPS
Before you install Python 3 on a Mac, you need to check Raspberry Pi
which operating system your Mac uses. To do this, click
the Apple icon in the top left of the screen and choose If you’re using a Raspberry Pi computer,
then you can skip the download
About This Mac from the drop-down menu.
step because Python 2 and Python 3
come preinstalled on the machine.

1 Download Python
Go to www.python.org and click on Downloads.
Remember this book uses Python 3, so
make sure you open the right version.
Click on the version of Python 3 that matches your You’ll find Python 3 in the Applications
operating system. The “Python.pkg” file will download menu on your Raspberry Pi. Open it
to your Mac automatically. now and check that it works.
The version number might not be exactly
the same as this one—just make sure it
has a 3 at the beginning.
Where should
I plug this in?
• Python 3.6.2 - 2017-08-15
• Download macOS X 64-bit/32-bit installer

2 Install Python
Double-click the “.pkg” file in the Downloads folder
to start the installation. Select Continue and then
Install to accept the default settings.

Click the package


to run the installer.
I better
get going!

3 Start IDLE
Once the installation is complete, check that it was
successful by opening the IDLE program. Search for
it in Spotlight or select the Applications folder, then
the Python folder, and double-click IDLE. A window
like this should appear.

Python 3.6.2 Shell


IDLE File Edit Shell Debug Window Help
Python 3.6.2 (v3.6.2:5fd3365926, Aug 15 2017, 13:38:16)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>>
18 G E T T I N G S TA R T E D

Installing EXPERT TIPS


Admin access
Pygame Zero Make sure you're signed into your
computer as an admin; otherwise,
the system won't let you install
Now it’s time to add some extra tools to things properly. Always ask
help you build great games. In this book, permission before installing new
you’ll need two additional modules—Pygame software on someone's computer.
and Pygame Zero. These are not included
with Python, so you need to install
them separately.
ACCESS DENIED

Installing Pygame Zero on Windows


Follow these steps to install the latest versions of
Pygame and Pygame Zero on your Windows computer.
Your machine needs to be connected to the Internet
to complete some of these steps.

1 Open the Command Prompt


Click Start. Scroll down and open the Windows 2 Install a package manager
A package manager called “pip” should come
System folder. Click Command Prompt. If you with Python when you install it. It’s a tool that
can’t find it, try searching for it. You’ll need to makes it easier to install Pygame Zero and other
type in some commands and press Enter to Python modules. Type this command into the
run each one. Make sure you spell everything Command Prompt and press Enter—it will
correctly and put spaces in the right places check if pip is on your computer and install
or it won’t work. it if it is not.

Command Prompt
c:\ python -m pip install -U pip

Look out for


this thumbnail
in the menu.

3 Install Pygame
Once the package manager is installed, 4 Install Pygame Zero
Finally, type this command. When you
type the following command and press press Enter, this will install Pygame Zero,
Enter. This uses pip to install Pygame. also known as pgzero for short.

pip install pygame pip install pgzero


I N S TA L L I N G P YG A M E Z E R O 19
Installing Pygame Zero EXPERT TIPS
on a Mac Having trouble?
Follow these steps to install the latest Installing these modules might be a bit tricky at first. If
versions of Pygame and Pygame Zero you’re having trouble, you can get the most up-to-date
on your Mac. Your machine needs installation instructions on the Pygame Zero website:
to be connected to the Internet to https://pygame-zero.readthedocs.io
complete some of these steps.

1 Open Terminal
You’ll need to use the Terminal app to >_
This is what the
Terminal app
thumbnail looks like.
install the modules. You can find it in your
Applications folder, or you can search for
it with Spotlight. Follow the steps below,
making sure all the spellings are correct Type this line carefully in the
and the spaces are in the right place. Terminal window and check for any
spelling errors and extra spaces.

2 Install a package manager


Homebrew is a package manager tool
Rabiahma – bash – 80x24

that makes it easier to install Pygame Zero Last login: Thu Sep 14 11:22:51 on ttys000
and other Python modules. Type in the LC-0926:~ rzvz ruby -e "$(curl -fsSL https://raw.git
command at right and press Enter to
install Homebrew. It might ask you to hubusercontent.com/Homebrew/install/master/install)"
enter your password again, and it will take
a short while to install, so don't panic if This should fit
nothing happens right away. on one line when
you type it in.

3 Check that Python 3 is installed


Homebrew will check if Python 3 is
brew install python3

already installed on your Mac and will Don’t put a


install it if it’s not there. Even though space before 3.
you’ve already installed Python, it’s
worth checking just to be sure.

4 Install other tools


Type in this command next and press
brew install sdl sdl_mixer sdl_sound sdl_ttf

Enter. It uses Homebrew to install some


tools that will be needed by Pygame Zero.

5 Install Pygame
Now it’s time to install Pygame. Type
pip3 install pygame

in this command and press Enter. I N S TA L L I N G

Install Pygame Zero


6 Finally, this last command will install
pip3 install pgzero

Pygame Zero.
20 G E T T I N G S TA R T E D

Using IDLE Look at


my pretty shell!
In IDLE, you can work in two different windows.
The editor window can be used to write and
save programs, while the shell window runs
Python instructions immediately.

The shell window ▽ Working in the shell


When you open IDLE, the shell window pops up. You can use the shell window to test out
snippets of code before you add them into
This is the best place to get started because you a bigger program. The code you type can
don’t have to create a new file first. You just type be run right away, and any messages
the code directly into the shell window. or “bugs” (errors) are displayed.
This line
shows the
Python 3.6.2 Shell version of
IDLE File Edit Shell Debug Window Help Python
you have.
These four Python 3.6.2 (v3.6.2:5fd3365926, Aug 15 2017, 13:38:16)
lines of code [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin The text here
are a simple will depend
drawing Type "copyright", "credits" or "license()" for more information. on your
program—try operating
>>> from turtle import *
it out for system.
yourself. >>> forward(200)
>>> left(90)
You type
>>> forward(300)
in code at
the >>> >>>
prompt.

EXPERT TIPS >>> print("You've unlocked a new level!")


Different windows
To help you know which window you should >>> 123 + 456 * (7 / 8)
type your code in, we’ve given each window
in IDLE a different color.
>>> ''.join(reversed("Time to play"))

Shell window
△ Give the shell a test run
Type each of these code snippets into the shell window
Editor window and press Enter after each one. The first line displays a
message and the second line does a calculation. Can you
figure out what the third line does?
USING IDLE 21
The editor window ▽ The editor window
The shell window can’t save your code, so when you To open the editor window
close it, the code you typed is gone forever. When you in IDLE, click on the File menu at
are working on a game, you should use IDLE’s editor the top and choose New File.
An empty editor will then appear.
window. This will let you save your code. It also has You’ll use the editor window to
built-in tools to help you write your programs and write the programs for the games
troubleshoot any errors. in this book.

You type in the code The name of the You can run Python programs from
here. This program file is shown here. this menu, but you will run Pygame
prints a list that tells Zero programs a different way.
you which numbers
are even and which
EvensandOdds.py
ones are odd.
IDLE File Edit Format Run Window Help
The menu bar for
for count in range(10): the editor window is
different from the one
if ((count % 2) == 0):
for the shell window.
print(count)
Anything you tell
Python to print print("is even")
gets displayed in
the shell window. else:
print(count)
print("is odd")

EXPERT TIPS
Colors in the code
IDLE automatically colors Symbols and names Output
the text to highlight Most code text is colored Any text produced when
different parts of the code. black. a program runs is blue.
The colors make it easier to
understand the code, and
they’re useful when you’re Built-in commands Keywords
trying to spot mistakes. Python commands, Certain words, such as if and
such as print(), are else, are special Python keywords.
shown in purple. They are shown in orange.

Errors Text in quotation marks


Python uses red to Any text in quotation
alert you to any errors marks is green. These are
in your code. called strings.
22 G E T T I N G S TA R T E D

Your first program EXPERT TIPS


Type carefully
After you’ve installed Python, Pygame, Make sure you type all your code
and Pygame Zero, follow these steps exactly as it’s written in this book.
to write your first Python program. The grid will help you get it all correct.
A tiny typo in just one line of code can
This simple program will display a cause a whole program to crash.
message on the screen.

How it works
This Python program will check if everything Start

is set up properly so you can start building


some games. It uses Pygame Zero to display
the word “Hello” on the screen.
Draw a message
on the screen

1 Set up a folder
Before you start, create a folder called python-games
somewhere easy to find, such as on your Desktop.
Create another folder within your python-games
folder and call it hello. End

Desktop △ Hello flowchart


When building a game, programmers use
python-games diagrams called flowcharts to plan their game
hello and show how it works. Each step is shown in
a box, with an arrow leading to the next step.
More complicated games might have steps
with questions and more than one arrow
leading to different boxes, depending on the
answer to the question.

2 Start IDLE
Open IDLE on your
File
Hello!
computer. From the New File
File menu, choose
New File to create an Open...
empty editor window
where you can write Open Module...
your program.
Recent Files ▶

Class Browser
YO U R F I R S T P RO G R A M 23

3 Type the first line of code


Write this first line of code that tells Python
to show, or “draw,” something on the Here we go!
screen. Press Enter when you’re done.

def draw():

This line of code is used


to print something on
the screen.

4 Type the second line of code


Then type in this second line of code. Check
that it starts with four spaces. This is called
an “indent,” and your code won’t work
without it!

def draw():
EXPERT TIPS

screen.draw.text("Hello", topleft=(10, 10)) Indents


Add four blank spaces Make sure you There should be four blank spaces at the
here if IDLE hasn’t have two closing start of the second line of your code. This
done it automatically. parentheses here. is called an “indent.” Python uses them to
separate different blocks of code. Spaces
and indents are very important—your code
5 Save the file
Now let‘s save the file. Go to the File menu and will not work if you miss them or put them
in the wrong place. They’re one of the most
choose Save As.... Name the file hello.py
and save it in the folder you created earlier. common bugs in Python programs!

Save As: hello.py


Tags: When you save a program,
IDLE adds “.py” to the end
Where: hello automatically, so you don‘t
have to type it in.

Cancel Save
Hey, grab on!
I’ll save you!

EXPERT TIPS
Saving your code
Always save your code before you run it,
especially after you make any changes.
If you don’t, Python will run an out-of-date
version of your code.
24 G E T T I N G S TA R T E D

Running your program


Because your games use Pygame Zero,
you usually have to run them in a different
way from normal Python programs. It isn’t
difficult once you get used to it, however.

6 Open Command Prompt or Terminal window


To run the program, you can use the command line. c:\ >_
If you’re using a Windows computer, this is in the
Command Prompt app. If you’re on a Mac, open
the Terminal app.
This is what the icon This is what the icon
for Command Prompt for the Terminal
looks like. window looks like.

7 Type in the Pygame Zero command


To tell Pygame Zero to run the game, type
Sanjay – bash – 80x24
pgzrun into the command line and leave Last login: Sun Sep 3 17:18:36 on ttys000
a space, but don’t press Enter yet!
LC-0797:~ sanjay$ pgzrun

Don’t forget to leave


a space after pgzrun.

8 Drag and drop the IDLE file


Keep the app open, and using Explorer (Windows) or
Finder (Mac), go to the folder where you saved your
program. Once you find it, drag and drop the .py file
into the command line.

Sanjay – bash – 80x24


python-games
Last login: Sun Sep 3 17:18:36 on ttys000
LC-0797:~ sanjay$ pgzrun User/Documents/python-games/hello.py
Name
hello
hello.py
Drag and drop hello.py The location of your
into the Command Prompt IDLE file will appear here
or Terminal window. when you drop it in.

9 Run the program


Now that you’ve typed in the pgzrun command 10 Final screen
If your program is working correctly, you’ll see
and your computer knows where to find the IDLE a window with a “Hello” message written in the
file, press Enter. This will launch Pygame Zero. top-left corner of the screen. Good job! Now
it’s time to become a Python games coder!
YO U R F I R S T P RO G R A M 25
EXPERT TIPS
Rerunning programs
When you’re building a program, you need to run the code
frequently to check for bugs. To save time, you can press the
Up arrow key in Command Prompt or Terminal to see your
recent commands. You can then press Enter to run one of
them again. If your game is still running, you need to close it
before rerunning your code. If you don’t, nothing will happen!

Running your program using IDLE


It’s possible to run your Pygame Zero programs using IDLE. To do
this you need to add two extra lines to your code. It’s a good idea to
wait until you have finish writing your program before doing this.

1 Type import pgzrun at the very top of your program and


pgzrun.go() at the very end. The entire code for your game 2 To run the game in IDLE go to the
Run menu and click Run Module,
should now sit between these two lines. or just press the F5 key.

This should now be the


first line of your program.
Run
import pgzrun
Python Shell
def draw():
Check Module
screen.draw.text("Hello", topleft=(10, 10))
pgzrun.go() Run Module... F5

This should now be the


last line of your program.

IMPORTANT!
Fix mistakes
If nothing happens when you run one of your programs, or if you
get an error message—don’t panic! It’s normal to experience I think there’s some bug
errors (these are called “bugs”) when coding a program. If an error spray on pages 44–47!
message appears, ask yourself the following questions:

▪ Does the code match the given example exactly?


▪ Have I saved the program in the right folder?
▪ Have I typed pgzrun correctly?
▪ Are Pygame and Pygame Zero installed correctly?
Learning
the basics

P Y T H N
O
Exploring the Variety of Random
Documents with Different Content
“Now we must have white rosemary. Wilt thou not gather it for
me?” she added, as Hugh, inert and dazed, was looking at her with
that weary longing, that infinite tenderness, which always made my
heart ache for his pain. “Dost know that white rosemary spells
remembrance?”
“Rosemary for remembrance!” he repeated, as quietly he turned
and with loving care picked the humble blossom from out the crowd
of its more gorgeous sisters. He looked at it, and as the light
flickered, I could see two great tears glistening in his eyes.
“Rosemary for remembrance!”—the very words spoke of England
and of home, and brought to his weary heart probably, more strongly
than anything else could do, the thought of what he had lost.
“Rosemary for remembrance!”—we, in England, thousands of
miles away, speak of the little plant as meaning remembrance;
before me, in one moment, with those words, the gorgeousness of
mystic Kamt had disappeared, and I saw its loveliest daughter filling
the old Chestnuts with the radiance of her beauty, the melody of her
voice. She became the incarnation of womanhood, of her who alone
knows how to combine the tender friend, the wife, the mistress.
There was dead silence in the temple. Neit-akrit had taken the bunch
of rosemary and was fastening it to her posy, while Hugh watched
her silently.
Then, suddenly, from the farther end of the sacred edifice, there
where the great gateway faced directly towards the east, it seemed
to me that a dull yet rosy light began to creep gently through.
“Neit-akrit,” said Hugh, after a long while, “if thou didst wish to give
me that posy as an emblem of happiness, it was wrong to add
remembrance to it.”
“Why?”
“Because since I have smelt that sprig of rosemary my memory
has come back to me. Remembrance, like duty, is at times cold and
cruel, and her figure now stands beside that gate and points towards
the east.”
“Nay, not yet!” she pleaded; “ ’tis but the lights of the city of Tanis
gone crazy with joy.”
“Remembrance whispers, Neit-akrit, that I have plighted my troth,
and that if I stay beside thee and chase remembrance away, I break
the pledge which I gave to another.”
“Nay! the heralds of dawn have not yet sounded the trumpets.
Osiris is still well hidden behind the hills, and my nosegay is not
ready. I have no tuberose, which means passion, and no white
pansy, which means forgetfulness.”
“It is not in thy power, Neit-akrit, to put white pansy into thy bunch,
and I…”
“And thou?”
“I would not put them there if I could.”
“Then, thou hast no wish to forget?”
“Rosemary, which is for remembrance, will be my most cherished
flower. Give me that one, Neit-akrit, out of the bunch… touch it once
with thy lips and then let the poor fool go his way.”
Ill, paralysed, numbed as I was, all my hopes tended towards the
beautiful girl who alone could keep Hugh away from the terrible
danger. I longed to give her courage to tell Hugh all, yet feared every
moment that she would, and that he would not believe, that his
loyalty to his bride should not allow him to listen to terrible
accusations framed against her by another woman. The moments
were precious; already through the distant gate the light of dawn
grew stronger and more clear.
“Nay! what is the use?” she said, as she drew a step back from
him; “thou dost seem to remember all that thou dost wish—thy duty,
thy word; the white rosemary should not come from me.”
“Sweet Neit-akrit, thou art a child,” he said with almost rough
earnestness. “Thou dost not understand—how couldst thou? I am a
senseless fool.… Give me thy hands to kiss… place them both upon
my mouth… for I dare not take them in mine… lest their touch should
indeed make me forget…”
Quietly she pulled from out the canopy of flowers a bunch of white
pansies, and stretching out both her hands up to him she murmured:
“White pansies for forgetfulness!”
He had fallen on his knees, and his arms encircled her dainty
figure. She turned towards the statue of the goddess as if to beg of
the cold, immovable image inspiration and perhaps strength. Ay! she
needed all her woman’s wits; there were a hundred unseen enemies
to fight, and one whom she feared more than any—the other woman
to whom he had plighted his troth. I suppose she found it hard to say
to him, “Beware, that woman has murdered her son; she even now
has planned thy ruin.” Supposing his loyalty forbade him to listen!
Her accusations to him might sound like the words of a woman mad
with jealousy… and she thought that she could not prove them; she
did not know I, too, had seen and heard, that I was here, close by, a
caged and useless log, a dumb beast, while twenty priests—a
hundred, if need be—were ready to swear that she lied.
And I was helpless—a caged, helpless, dumb creature—and the
minutes were speeding so fast.
Suddenly from afar the sacred heralds of Osiris rang out upon
their golden trumpets the announcement of the sun-god’s approach.
In a moment Hugh had sprung to his feet, but Neit-akrit now would
not let him go; she clung to his garments, dragged at his cloak.
“Thou must not go,” she entreated. “The temple is dark and lonely
—I am frightened; for pity’s sake do not leave me!”
“Nay, sweet! thou art safe enough here… for the love of heaven
take thy dear hands from off my cloak!”
“Thou wilt not leave me?”
“I must go, sweet. Remember I have sworn! wouldst make a
coward of me?… Nay! thou hast all but succeeded… be satisfied
and let me go!”
She took her hands from off his cloak, but came up close to him
and whispered:
“See! I do not hold thee, and yet thou wilt not go… thou art free!
and yet thou wilt stay… thou hast smelt the perfume of the white
pansy, and thou wilt forget all… save that thou dost love me.…”
“Neit-akrit!”
“Nay! thou dost entreat in vain.… Sweet, I would not have thee go!
What is duty? what is the meaning of oath or pledge? Wouldst know
why I came to-night?… I came because I knew that danger doth
await thee outside this sacred temple.… I came because I knew that
thou dost love me… and I trusted that that love would make thee
forget the dawn, thy duty, thy pledged word, forget all, in order to
remain beside Neit-akrit.”
“Forget? Ay! I have forgotten but too long already. Neit-akrit, thou
speakest of danger; to me there is but one, and that is that I might
forget all—my manhood, my honour, my pledge, my word, might
forget thy innocence, and remember only that thou art fair.”
“But that is all I would have thee remember,” she whispered so
softly that her voice hardly sounded above the murmur of the flower,
which some stray current of air began gently to fan. “If I am fair it is
because Isis hath made me so in order that thou shouldst love me! I
am young, and I have waited for thee all these years because,
although I knew it not, I wished that my beauty should gladden thine
eyes. Nay! at first I longed for thy love out of sheer pride and
revenge. Dost remember the iridescent scarabæus, which should
have guarded thee from the peril of giving thy love to Neit-akrit?
Sweet! ’twas I stole the scarabæus. I would not have thee turn coldly
from me; thou hadst taken from me my crown and my throne; I
wished to steal thy heart from thee, and then to break it in wanton
cruelty, and I threw the charmed scarabæus into the lake.… Then
thou didst speak to me… I looked into thine eyes… I knew thy soul
was mine… but… I guessed even then, my sweet, that Isis had
made me doubly fair, had placed radiance over my body and my
soul, for that day I learnt… that I loved thee!”
“Neit-akrit, for pity’s sake,” he pleaded.
But her arms were round his neck, her sweet face quite close to
his, her eyes looked ardently into his own.
“I love thee!” she whispered.
“Wouldst make me mad, Neit-akrit?”
“I love thee!”
And far, very far away, the sacred heralds of Osiris rang out upon
their golden trumpets the announcement that the sun-god was
emerging behind the hills of Kamt, which hid the valley of death.
“I love thee, oh thou who art beloved of all the gods!”
Hugh had clasped her in his arms, and as I closed my burning
eyes and fell back fainting in my prison, I knew that he was safe, that
Neit-akrit had succeeded in making him forget.
CHAPTER XXVIII.
THE THREAT

Shuffling footsteps, muffled whispers and hard breathing were the


first sounds which greeted my dulled senses when once again I
woke from one of those strange and fitful sleeps in which the
mysterious poison held me periodically enthralled.
Through the marble tracery brilliant daylight came peeping in,
making the sanctuary lamps appear pale and ghost-like. My head felt
less heavy, and my eyes were less painful. It seemed to me that the
shuffling steps drew nearer, and as they approached the whispers
ceased. I was still a prisoner, but my brain was fully alert, and soon I
perceived that two forms, swathed in white, had paused a moment
beside the gateway.
I made an earnest appeal to all my wits, and, holding my breath,
crouching against the wall, I waited. Soon a refreshing current of
outer air told me that the gateway had been opened, that if I kept my
wits about me, my one chance of deliverance had come.
Like the flash of a sudden instinct, the thought came to me that
perhaps some one was coming to see whether the deadly narcotic
had thoroughly accomplished its work; or perhaps, after all, Hugh
had fallen into the awful trap, and it mattered nothing if I were
prisoner or free. With my mind filled with terrible doubts and
presentiments, I yet had the strength to remain perfectly still: I
guessed what I ought to look like, if indeed I were still under the
influence of the drug, and crouching, with my head buried between
my knees, I waited.
The shuffling footsteps came quite close to me, a cold bony hand
forced my head back, then allowed it to fall again; a muffled voice
murmured:
“Some more?”
“Ay! perhaps, for safety,” replied another.
This was the crucial moment. Weak as I was, another whiff of the
poison would perhaps render me helpless for ever. I heard a click
like the opening of a metal box, which then was placed on the floor
close beside me. I had been a good diver and swimmer once. I could
hold my breath for a good sixty seconds, and already the shuffling
footsteps were hastily retreating from the poisoned atmosphere. I
crawled upon the floor, flat as a serpent; I had need of my breath
now—and the stupefying odour reached my nostrils in one terrible
whiff. The white-robed figures were in the doorway: my deadly peril
gave me one last flicker of strength: with a sudden movement I
stretched out my hands, and caught hold of one of the sandalled feet
before me: the priest tripped and measured his length upon the floor,
at the very moment that I was trying the same schoolboy trick upon
his companion. While, stunned and bruised, they sprawled upon the
ground, and, frightened by the sudden shock, tried to struggle to
their feet, I had crept past them out by the marble gateway. The
fresh air from without put renewed strength into me, while my
enemies were probably tasting the noisome odour with which they
had sought to render my sleep an eternal one.
My knees shook under me and I felt hideously sick and stiff; but I
struggled on from pillar to pillar, skirting the gigantic temple, which
had never seemed so vast to me. I wished to reach the farther
gateway, find Hugh if he was still there… if not… well! if he had
gone, I would still find him, somehow, now that I was free.
The great gateway was open—exhausted I leaned against it: my
legs would carry me no farther.
“Girlie!” I gasped.
He must have been standing quite close to the entrance, for he
heard me, and the next moment had half dragged, half carried me
within the temple and laid me down on the floor, with my head
resting against his shoulder.
“Mark! in heaven’s name, what is the matter?”
“Nothing is the matter now,” I said, as audibly as I could, “now that
I have found you and that you are safe.”
“What in the world do you mean? You can hardly talk! you are ill!
Let me take you to the pavilion.… I can look after you there and you
can try to tell me.…”
I shook my head vigorously.
“No, Girlie! the moments are precious.… I have been drugged,
stupefied and caged up, so that I might not get to you, and tell you.
Listen, Girlie…”
And as best I could, in jerky, half-choked sentences, I told him all.
He listened without a word, then said quietly:
“Ur-tasen shall pay for this. She came, Mark… you knew it; saw
her perhaps… she put her arms round me, and kept me a
prisoner.… A little while ago she slipped away… and left me alone
with my dream.”
“Ur-tasen will not rest content in the midst of failure,” I said. “Pray
to God he does not play us some terribly cruel trick yet.”
“Dost speak words of wisdom to thy friend, oh! wisest of
counsellors,” said a loud sarcastic voice close behind us, “or dost
adjure him to pray to his God to watch protectingly over his head?
Whatever else thou sayest, tell him one thing, in that language which
comes from beyond the valley of death, and that is, that Ur-tasen will
not rest content in the midst of a failure. In the language which he
speaks there is no such word as fail.”
Hugh had jumped to his feet and confronted the high priest of Ra,
who from some remote corner of the temple had crept noiselessly
close to us.
“What dost thou mean? Why art thou here?” demanded Hugh. “Art
bold indeed, Ur-tasen, that thou darest stand before me and my
wrath.”
“Bold indeed, oh! son of Ra!” replied the high priest, making a
mock obeisance. “Ur-tasen now hath no cause for fear… he is an old
man, and thy hands are mighty and strong, and yet the old man, with
one foot in the grave, hath struck a blow at thee which will crush thy
life, and wither thy manhood, and throw thee, a weak and puling
coward, at the foot of him whose power thou hast defied.”
“What dost thou mean? Speak! Thou hast not many moments of
peace before thee, for I will make thee answer for thy treachery
against my friend.”
“Ay, I am willing to bear the full brunt of thy wrath, oh! stranger who
hailest from the foot of the throne of Osiris.… Thy counsellor hath no
doubt told thee that I and Maat-kha did plot against thee. He says so,
and thou dost believe.… I care not to deny; we failed, she and I…
and whatever crime she hath committed she must atone for,
according to the laws of the land. But thinkest thou perchance that
Ur-tasen did rest content? didst think that a weak and passionate
woman could throw herself across his plans? Fools were ye both!
oh! thou who dost style thyself the son of Ra, and she… who once
was called Princess of Kamt.”
“Name her not, thou infamous priest,” said Hugh, raising his hand,
as if ready to strike the miscreant; “I forbid thee to speak her name!”
But Ur-tasen shrugged his shoulders, with a low sarcastic chuckle.
“Nay! I will not name her, since it rouses thine anger; but anon it
will not only be I, but all Tanis who will shriek out her name in
loathing and execration.”
I had struggled to my feet and was clinging with all my might to
Hugh, for I could see that he could scarcely restrain himself from
strangling the old man, then and there. But I felt that at any cost we
ought to know what nefarious scheme he had concocted, and my
heart filled with awful forebodings, I whispered to Hugh:
“Girlie!… for her sake… find out first what he means. Then I will
help you to murder him, if you like.”
“Dost thy counsellor whisper prudent advice in thine ear, oh!
beloved of the gods? Nay, then! do thou follow it. Thou wilt need to
be calm… if thou canst. Thou hast played a losing game, oh! son of
Ra, and now wilt find that it was not good to defy the might of the
priests of Kamt. I could not destroy thee and thy fame, the evil power
of Set protects thee; I know not, perhaps thy body is invulnerable…
thou art strong, and the people love thee. A hundred priests are at
my command, yet not one of them would dare to lay hands on thee.
But thou hast a soul, oh! mighty son of Ra! a soul which I, thine
enemy, have known how to torture, with a torture so exquisite that
anon it will unman thee. Thy soul,” he added, with a loud triumphant
laugh, which sounded weird and demoniacal, as it went echoing
through the vastness of the temple, “thou didst give it to one who
was beautiful and great, and praised above all. Dost know where she
is now, oh! beloved of the gods? A prisoner in the hands of the
priests of Isis, who seized her, even within the precincts of the
temple of the goddess, while thy kisses were still warm upon her
lips.”
“Thou liest,” hissed Hugh with smothered rage. And he raised his
hand and struck the evil-mouthed priest an ugly blow upon the face,
so that a few drops of blood began to trickle down his gaunt cheeks.
“Thou liest!”
“Nay! Thou knowest well that I do not lie,” replied Ur-tasen, who
literally had not turned a hair under the terrible insult. “The priests of
Isis had noticed the women of Princess Neit-akrit standing about
outside the temple at dawn. They warned me and I ordered them to
watch. Osiris had not made a long journey in the heavens when from
out the gates of the sacred edifice they saw a woman glide. The
priests of Isis waited… she parted from her lover at the gate.… They
saw it all… the laws of Kamt are severe upon the sin of unchastity,
and a sin committed within the temple is doubly heinous… that
woman was Neit-akrit, Princess of Kamt. Before her women could
reach her she was a prisoner, and now awaits her doom for the
crime she hath committed.”
But like a madman Hugh was upon him, and his powerful hands
had clutched the old priest by the throat.
“Man, thou art bold indeed,” he whispered in his ear, “to stand with
such a tale before me and my wrath! Dost know that if that tale is
true, that if thou or thy priests do harm but to one hair of Princess
Neit-akrit’s head, I will kill thee, even where thou dost stand?”
Ur-tasen made not a movement, only his eyes started out of their
sockets, and his lips parted, for the grip round his throat must have
been very tight. At last he began in a choked voice which gradually
grew stronger and firmer as Hugh relaxed his hold:
“Kill, oh! son of Ra!… kill! if it is thy will! Dost think I would make
the faintest struggle? or call my priests to my aid? There are a
hundred well within my call, and yet, see! I do not even raise my
voice. Kill me! Ay! how gladly would I die, knowing that my death had
at last encompassed thy ruin, after I had succeeded in wrecking thy
soul. Ay, I think we are quits, oh, beloved of the gods, who with thy
mighty hand didst break the wand of office of the high priest of Ra. In
exchange for that wand I have broken thy heart, and I will die happy,
knowing that that which thou lovest best in all the world will become
more abject, more pitiable than Kesh-ta, the slave, whom thou didst
snatch from out the clutches of the inexorable justice of Kamt.…
Nay, why dost thou hesitate? In the name of Ra, thy sire, and Osiris,
whose beloved thou art, strike, oh, emissary of the gods! strike! and
with the blow which sheds the blood of the high priest even within
the temple which it will desecrate, perhaps the people of Kamt and
the priests of their gods will waken from the spell which thou hast
cast over them with thy magic. Strike! for beyond that one act of
brutish force, thou art powerless! Neit-akrit is a prisoner in the hands
of the priests of Kamt. Hidden from all eyes, none can know where
she is. Her sin, in this land, is not judged in open court, nor doth
anyone hear judgment pronounced upon her.… But, to-morrow, a
being—blind, maimed, bruised, who once was the fairest in ancient
Kamt, will beg in the streets of Tanis for the charity of the passer-by,
and scornful fingers will point pityingly at her and say, ‘’Tis Neit-akrit,
once Princess of Kamt, who sinned even within the temple of the
goddess!’ Ay, thou mayest strike, oh, beloved of the gods, for within
the grave where my body will quietly await the return of my soul,
there will be joy and happiness in the thought that thou, mighty as
thou art, beloved of the gods and worshipped in all Kamt, canst do
nothing to save her from that doom.”
Gradually Hugh’s hands had dropped from off the priest’s throat. I
could see that all his furious rage was outwardly gone; he was as
pale as death, only his eyes glowed with a weird fire, and his arms
were crossed tightly over his chest.
He waited with seeming patience until the high priest had finished
speaking, then he said very calmly:
“And didst thou really think, oh, mighty priest of Ra, that events
would shape themselves even as thou hadst cunningly devised?
Didst really think to find it so easy to pit thy power against mine, and
remain the conqueror? Truly, I pity thee! thee and thy blind folly.
Thou comest here before me, calm and triumphant, to tell me that
she whom I worship is a prisoner in thy hands; that she, who to me is
akin to a divinity, is to be vilified and slandered by impious priests, is
to be disgraced, nay, worse, tortured, and then calmly dost say that I
can do nothing to save her from her doom. I, the stranger who did
break the impassable barriers which since five thousand years have
hidden the secrets of Kamt, I can do nothing to save my most
cherished treasure? Well, perhaps not! perhaps, fearing that some
terrible doom might overtake thee before thou hadst time to
accomplish thy criminal resolve, thou hast already dared to lay
hands on my divinity! Then indeed, thou art right. Even I cannot undo
the past, I cannot save her from her doom! But hast thought of
afterwards, oh, mighty priest of Ra?”
“Afterwards?” he asked, with a quiet shrug of the shoulders.
“Ay! Afterwards! Didst think, perchance, that, having in my wrath
sent thee and thy vile body, broken into a thousand atoms, into the
darkest corner of the valley of death, I would suffer the extreme
penalty of the laws of Kamt, and give thy wandering soul the
happiness of seeing my shrivelled body withering by starvation, and
rotting beneath the claws of the vultures in the desert? or didst think
that, shuddering from a crime, I would wander about the cities of
Kamt, a broken-hearted and miserable coward? Hast forgotten who
and what I am, oh, mighty priest of Ra, when thou didst think I would
ask aught of thee? Hast forgotten that I hold the hearts of Kamt and
of its priests in the palm of my hand, and its allegiance at my feet;
that from the inaccessible heights of my throne, built upon the love or
superstition of the people, I do not ask, but I command thee never to
dare lay one of thy fingers upon the person of Princess Neit-akrit, not
to allow one breath of slander to touch the purity of her name; and if
thou, in thy presumption, shouldst perchance dream of disobeying
my commands, shouldst think that within the hallowed precincts of
thy temples thou canst defy me, then, for the first and last time, Ur-
tasen, I bid thee beware! for not upon thy puny body alone will fall
the weight of my wrath, not my hand alone shall descend upon thy
enfeebled shoulders, but my voice, which now maketh Kamt half-
mad with joy, will then be raised to kindle into its people thoughts of
evil and of blood; the spell of my magic will hover over their heads,
whispering of murder, of incest and of sacrilege; a mist of blood will
swim before their eyes, and from Tanis to Net-amen, from Men-ne-
fer to Khe-me-nu, I, as the new prophet of evil, will carry before me
the burning torch of a bloody revolution. And, ye who are mighty, ye
who are rich, and, above all, ye who deem yourselves sacred, pale
and tremble! for I will speak unto the people who follow me of
desecration and of sacrilege! Ay, even I, who but yesterday spoke of
mercy and justice! And the people of Kamt will follow me, Ur-tasen,”
he added, as, drawing himself up to his full height, he seemed
already to tower above the terror-stricken man as some inspired
prophet of evil. “Man is ever ready to listen to the voice which would
beckon him back to his original level of savage beast. They will
follow me, and become mad with fury, thirsting for carnage, for
murder and for bloodshed; they will hurl the rulers from their thrones,
destroy their temples and desecrate their tombs! And thou, Ur-tasen,
who art the embodiment of that priesthood which hath kept the
people of Kamt in superstitious ignorance, against thee and thy
priests will the scorn, the loathing, the outrage tend. Buffeted and
scorned, thou wilt stand at the very foot of the throne of thy god, as
within a pillory of shame; men, women and children will howl and
hoot at thee, will point to thee with scornful fingers still reeking with
blood, and thou wilt see in that land which thou hadst hoped to rule,
man murder his brother, woman her child, child its parent; thou wilt
see rape and theft and sacrilege rife, thou wilt see famine and
pestilence. And when every foot of the land of wheat and barley hath
been polluted by crime, and every temple been desecrated, when
the people of Kamt have sunk to the level of the wild beast, then, at
a final word from me, they will, with superhuman effort, wage war
against Nature herself, and tear down bit by bit every shred of that
barrier which thou and thy priests did build around their land; they
will tear down palaces and temples, hurl down marble pillars and
alabaster steps, set fire to the four corners of the mighty kingdom, till
stone does not remain upon stone, and in one vast and burning ruin
bury at last their rulers and their priests, their glorious history and
their ignoble shame.”
Superstition and terror had gripped the high priest by the throat
more firmly than Hugh’s fingers had done before. He grew gradually
more livid and more pale; his lips, from which a few drops of blood
still slowly trickled, began to twitch and tremble, and once or twice he
stretched out his arms towards Hugh as if appealing for mercy.
Hugh was playing a bold game. The woman he loved was in a
terrible plight, and his hold upon the people of this land was entirely
one of superstition and mysticism. It seemed to me as if from the
distance, in the temple, I could hear terrified groans, and I thought
that I saw white and ghostlike shadows rush frightened hither and
thither.
Hugh had finished speaking, and still the powerful echo of his
voice lingered among the pillars: the high priest had buried his face
in his hands. He was silent for a while, struggling against his own
fears, then we heard his voice, hoarse and trembling, whisper softly:
“Who and what art thou?”
“One who has but one word, one pledge,” replied Hugh; “who
never speaks but of that which he can accomplish.”
“Thou art the soul of Set, the power of evil, descended upon earth
to bring sorrow in thy trail.”
“I brought joy and happiness when I came; upon thy head rest the
burden of desolation and of sorrow.”
“I have not sinned,” he said, almost in entreaty; “Neit-akrit is still
safe… a precious hostage in my hands,” he added, noting Hugh’s
sudden look of infinite relief, “that which thou dost hold most dear,
and yet hast overwhelmed with sorrow.”
“Name her not, Ur-tasen,” interrupted Hugh; “she is as pure and
holy as the goddess whose image thou dost worship.”
“Nay, I had no evil thoughts of her,” replied Ur-tasen, quite humbly;
“I was speaking of sorrow; thou canst not command so intangible a
thing to keep clear of her path. Thou hast sworn to wed Maat-kha: as
long as she lives, thy love for another can but give sorrow and
shame. And Maat-kha will live! None saw her do the evil deed save
thy counsellor!… will he accuse her before the awful judgment seat
of Kamt?
“Thou hast conquered, oh, beloved of the gods,” added the high
priest, with sudden strange eagerness. “See! I, who had defied thee
and thy might, am the humblest of thy slaves; and yet, mighty as
thou art, thou canst not, whilst thou art in the land of Kamt, change
thy destiny and hers! Thou art wedded to a murderess, and Neit-akrit
cannot sit upon the throne of Kamt. For thoughts of thee she will not
wed another; sorrowing she will turn to the gods for comfort, and
seek refuge against a guilty love in the vows of a priestess of Ra.
Nay!… What canst thou do?… thou art mighty!… but it will only be
when all the gods of Kamt are dethroned, and all their temples
desecrated, that thou canst break the bonds which bind thee to
Maat-kha, or place in Neit-akrit’s hand the sceptre of a queen.”
The high priest paused again, and once more his keen eyes
searched those of Hugh. We held one another tightly grasped by the
hand: I think we both felt that we were nearing the final crisis in our
strange and weird adventure.
“Thou art mighty, oh, beloved of the gods,” whispered Ur-tasen, so
low that we could scarcely hear; “thou art great, and the people of
Kamt do worship thee… and I, the most powerful in the land, more
powerful than any Pharaoh—for I rule over the dead as well as over
the living—I do grovel at thy feet. Call forth the people of Kamt… let
them come in hundreds and in thousands, and in tens of thousands!
let them come to Men-ne-fer… to see the high priest of Ra kneeling
humbly before the emissary of the gods, and with his hands tying the
sandals upon the stranger’s feet.…
“It is a great and glorious festival,” he added with growing
eagerness, seeing that Hugh and I had, in a flash, realised what was
passing in his mind. “The most exquisite products of the land will
decorate the temple of the god.… In the middle of the sanctuary,
upon a throne of gold, surrounded by the priests of Ra, there will
stand he who is beloved of the gods… the festival shall be great and
glorious, but sorrow will be in the hearts of all the people of Kamt…
for the son of Ra, the emissary of the Most High… will return to the
heavenly land… from whence he came.”
Hugh did not speak; in his eyes I read the awakening of a great
hope—an infinite peace and relief; he had guessed that the high
priest, terrified and humbled, was, of his own accord, begging for
that which Hugh even would never have had the power to force him
to grant.
“But in the hearts of the people of Kamt,” added Ur-tasen, finally,
“there will for ever dwell the memory of him who first in the judgment
hall of Men-ne-fer spoke to them of mercy and of truth; and at even,
when Isis is high in the heavens, and ties of home and love bring
men and women together, they will talk of him who was beloved of
the gods, who left the land beyond the blue vault of heaven to dwell
for a while upon Kamt. Then Maat-kha, twice a widow, will weep
shuddering over her sin, and Neit-akrit, Queen of Upper and Lower
Kamt, will dispense truth and justice to her people, while dwelling on
the fond memory as upon a happy dream—the memory to which will
be attached neither sorrow nor shame.”
He had sunk down upon his knees—a humble, cringing suppliant,
and his shaven crown rested upon the floor, at Hugh’s feet, which he
was kissing like any abject slave.
“Mark, old fellow, this is happy deliverance, is it not?”
“Do you wish to go, Girlie?” I asked.
“How can I stay? This man has said it truly, I am wedded to Maat-
kha; my love can only bring sorrow on her whom I worship, shame
perhaps… and I…” he added with a sigh, “I could not live now here,
without her, while I am a prisoner in this land.… When I am gone… I
think… we should both forget.
“Listen, Ur-tasen,” he said after a little while, “I still have much to
say to thee. See that the Princess, whom thou hast outraged, is
respectfully conveyed to her palace. The priests who have dared to
lay hands upon her must grovel humbly at her feet until she hath
deigned to forgive; if she chooses to mete out a punishment to them,
then see that it is carried out, whatever it may be.… When that is
done, do thou go back to Men-ne-fer.… I and my counsellor will
follow later on.… Within thy temple I will speak to thee again.”
“Then… thou dost consent, oh, beloved of the gods?” whispered
Ur-tasen, without daring to look up.
“Nay, I know not! Remember… I make no compact.… I cannot
say.… But I fain would see what reparation thou canst offer to
Princess Neit-akrit, and I must speak with my counsellor.”
“Wilt deign to allow the servants of the temple to accompany thee
to the palace? The Pharaoh is dead… Maat-kha is Queen, and thou
art the holy Pharaoh, since thou art her lord.”
“Nay, I would be alone with my counsellor. Go, Ur-tasen! ’Twere
best that thou who wast witness to her crime shouldst tell Maat-kha
that I know all.”
“I am ever ready to obey thy commands, oh, beloved of the gods,
and in all Kamt thou dost not own a more humble slave than Ur-
tasen, the high priest of the Most High.”
Painfully he struggled to his feet: he seemed a broken-down old
man now. When, after another deep obeisance, he turned to go, we
remarked that he did no longer walk erect, that his humiliation had
bent his tall figure, and placed the full weight of his years upon his
shoulders.
CHAPTER XXIX.
THE DEPARTURE FROM TANIS

That same afternoon we left for Men-ne-fer. Tanis perforce had to


put aside her bridal finery and plunge herself into mourning. All day
the scribes of the temple ran up and down the streets, shouting at
the top of their voices that the holy Pharaoh was dead; that he had
succumbed to his many ailments in the arms of the priests of Isis,
who had helped to soothe his dying moments. His mother, broken
down with grief, could not be persuaded to leave his lifeless body,
and would remain in Tanis until such time as, the elaborate process
of embalming being completed, the dead Pharaoh would be ready to
be conveyed to Men-ne-fer, for the solemn obsequies.
Hugh had tacitly allowed this version of the Pharaoh’s death to be
spread among the people. He had no wish to publicly accuse her
who already was his wife in name, and hand her over to the cruel
justice of her country. No doubt she suffered enough. Hugh would
not see her, and she had been told that he knew of her crime.
When, having taken farewell of lovely Tanis, our boat began to
glide slowly along the canal, it seemed to both of us that on the
height where stood the royal palace we saw a figure swathed in
black, sharply defined against the white background, stretching out
its arms entreatingly towards our fast disappearing boat.
Tanis in sorrow had not dared to speed our departure with shouts
of farewell, nor did the snow-white city, coquettish in her perpetual
bridal attire, know that the son of Ra was leaving her never to return.
Hugh had not hesitated a moment. He longed to get away, and I
confess that I viewed the prospect of leaving this strange exotic land
for ever without the slightest pang.
“We will make our own terms with Ur-tasen,” said Hugh; “and I
promise you our return journey will not be attended with any
privations.”
“You are glad to go?” I asked.
“Very glad,” he replied earnestly. “She will be happy… and we
shall both forget.”
As long as we could, we watched the white city gradually growing
more hazy and dim, until at last a turn in the canal, a thick clump of
papyrus grass hid it entirely from our view; even then it seemed to
me that the echo from sistrum and harp, the strange songs of the
priestesses of Isis, hovered for some time in the air.
The journey from Tanis to Men-ne-fer direct was a long one. We
spent two nights beneath the canopy of our boat, lulled to sleep by
the rhythmic clap of the oars and the monotonous lullabies sung by
the boatmen. The third night we passed before the palace of Neit-
akrit.
There was no moon, and it was very dark all around; the marble
palace hardly appeared as an outline against the heavy sky, only the
gigantic sphinxes seemed to frown down upon us in the gloom. A
warm breeze was in the air, and as the boat glided swiftly past the
great fuchsia trees gave forth a long and melancholy sigh. We
neither of us spoke; but by the dim light of the lamp at the poop I
could see that, for a long time, Hugh watched that ghostlike palace,
those fuchsia trees, whose snow-white walls, within which he had
buried his earthly paradise.
We neared Men-ne-fer towards the early morning, and, after a rest
in the palace, we went to meet Ur-tasen in the temple of Ra.
He looked to me very much aged, and anxiety had traced many
more lines on his face. He met Hugh very eagerly, but knelt humbly
on the floor, waiting for him to speak.
“Where is Princess Neit-akrit?” asked Hugh.
“To-night her boat will have reached her palace, where she has
decided to remain until the obsequies of the dead Pharaoh, when
she will come to Men-ne-fer,” replied the high priest, humbly, and
almost in a whisper.
“And those priests who dared lay hands upon her person?”
“They await her pardon in the vault beneath the temple of Isis. But
I do not doubt that Neit-akrit will grant it.”
Hugh breathed a sigh of relief. There was no doubt that Ur-tasen
had not even thought of defiance; moreover, we gathered from this
that, though he feared and hated the beloved of the gods, he did not
distrust him.
“What dost thou know of the land which lies beyond the gates of
Kamt?” asked Hugh, abruptly, after a slight pause, during which he
had scanned with a scornful frown the figure of the high priest
kneeling at his feet.
“Nay, I know nothing, oh, beloved of the gods. I care not to know,
whatever in my dreams I may at times have guessed. Never hath
foot of man crossed the valley of death and lived.”
“Yet I came. Dost know from whence?”
“Thou saidst it: from the foot of the throne of the gods.”
“Ay. And thither will I return, taking with me the hearts of the
people of Kamt. Now listen to my commands, and ’twere well for
thee that thou seest that they are implicitly obeyed. From among thy
priests choose those whom thou wouldst trust, as thou dost trust
thyself, who, like thee, know that beyond the valley of death there
lies some other land, and do thou tell them that I would visit it. Then
bid them secure eight sturdy oxen and two light but roomy carts, to
each of which four oxen should be yoked. These beasts and carts
must be lowered through the gate of Kamt into the valley of death.
The priests whom thou wilt have chosen as being silent and discreet
shall load the carts. In one they shall place sixty gourds, each
containing two measures of water, and two gourds, each containing
three measures of wine; two sacks of dried dates and figs, and five
jars of dried fish and goose’s flesh; the other cart must be heaped
with oil cakes, barley and dried grass, in as great a quantity as the
four oxen can bear quite easily. When the carts are ready and
loaded and the oxen put to, bid thy priests choose a healthy cow and
tether her to one of the carts. At dawn thou shalt accompany me and
my counsellor to the gates of Kamt, and thou shalt cause thyself to
be lowered into the valley of death, before I myself do follow thee.
Thou shalt come with me across the wilderness as far as the Rock of
Anubis, against which, if thou hast in any way disobeyed me, or
played me false, I will chain thee and bind thee, and leave thee to
starve slowly amidst the carrion. But if thou hast punctually obeyed
my commands, thou canst then return: thy priests, in the meanwhile,
can keep a watch for thee.”
The high priest made no comment, but merely asked quietly:
“Are these all thy commands, oh, beloved of the gods?”
“All, as regards my journey hence. Before I leave thou shalt
proclaim from the foot of the altar of thy gods that I, their emissary,
have returned from whence I came, that my mission among the
people of Kamt is fulfilled, for I came by the will of Ra himself to
infuse mercy into their laws. No man or woman shall in future be cast
out living from Kamt, to die of starvation in the wilderness; no man or
woman shall, for any sin or crime, suffer torture or mutilation. This
thou shalt proclaim from the inner sanctuary of Ra, even while I,
ready to go upon my journey, will listen from the outer precincts,
which lead to the gates of Kamt, and hear that thou dost do my
bidding. Then, when thou hast done that, thou shalt tell the people
that I enjoin them, as a parting wish, to honour and reverence Neit-
akrit, their Queen, whom Ra himself, by my mouth, hath decreed
shall rule over them as long as she lives whether she take a
husband or no. She shall be the sole and mighty Pharaoh, and on
her head alone shall rest the double crown of Kamt.”
Ur-tasen’s face brightened up. It was obvious that Hugh need
have no fear that this parting injunction of his should not be implicitly
obeyed. The high priest of Ra, in spite of all, was still under the
magic spell of beautiful Neit-akrit.
There was nothing more to be said, and we left the temple of Ra to
have a final look at the land which we had found so fair.
I was glad to leave it; the gilded cage had somehow become an
intolerable prison, but… it was a parting, and all partings are sad.
The people of Men-ne-fer did not know that their idol was leaving
them; though the death of the Pharaoh had thrown outward gloom
over the city, they made no attempt to restrain their enthusiasm, their
delight in having him in their midst again, who was beloved of the
gods.
The picture of that day in Kamt is one of the most vivid in my
memory. The sun was dazzlingly bright, and Men-ne-fer—gorgeous
Men-ne-fer with its rose-tinted palaces, its temples and gardens and
market squares—displayed before our saddened eyes all the
splendours of its beauty. The royal palace, on the steps of which the
pale pink flamingoes stalked lazily in the heat of the mid-day sun, the
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like