Coding Projects in Scratch 1st Edition by Jon Woodcock ISBN 1465451420 9781465451422
Coding Projects in Scratch 1st Edition by Jon Woodcock ISBN 1465451420 9781465451422
com
https://ebookball.com/product/coding-projects-in-
scratch-1st-edition-by-jon-woodcock-
isbn-1465451420-9781465451422-15784/
OR CLICK HERE
DOWLOAD EBOOK
ebookball.com
ebookball.com
ebookball.com
C Gotchas Avoiding Common Problems in Coding and Design
1st Edition by Stephen Dewhurst ISBN 9780672333774
0672333775
https://ebookball.com/product/c-gotchas-avoiding-common-problems-in-
coding-and-design-1st-edition-by-stephen-dewhurst-
isbn-9780672333774-0672333775-12368/
ebookball.com
https://ebookball.com/product/employment-a-key-idea-for-business-and-
society-1st-edition-by-jamie-woodcock-
isbn-1032247258-978-1032247250-24542/
ebookball.com
https://ebookball.com/product/secure-coding-in-c-and-c-2nd-edition-by-
robert-seacord-0321822137-9780321822130-16224/
ebookball.com
ebookball.com
codin G
PrOJEcts
scratch
tM
IN
codin G
PrOJEcts
scratch
tM
IN
jon woodcock
DK UK
Senior editor Ben Morgan
Senior art editor Jacqui Swan
US editors Jill Hamilton, Margaret Parrish
Jacket design development manager Sophia MTT
Jacket editor Claire Gell
Producer, pre-production Gillian Reid
Producer Mary Slater
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 DELHI
Project editor Suefa Lee
Project art editor Parul Gambhir
Editor Sonia Yooshing
Art editor Sanjay Chauhan
Assistant art editor Sonakshi Singh
Jacket designer Suhita Dharamjit
Managing jackets editor Saloni Singh
DTP designer Jaypal Chauhan
Senior managing editor Rohan Sinha
Managing art editor Sudakshina Basu
Pre-production manager Balwant Singh
A catalog record for this book is available from the Library of Congress.
ISBN: 978-1-4654-5142-2
DK books are available at special discounts when purchased in bulk for sales
promotions, premiums, fund-raising, or educational use. For details, contact:
DK Publishing Special Markets, 345 Hudson Street, New York, New York 10014
[email protected]
Printed in China
A WORLD OF IDEAS:
SEE ALL THERE IS TO KNOW
www.dk.com
DR. JON WOODCOCK MA (OXON) has a degree in physics from the University of Oxford
and a Ph.D. in computational astrophysics from the University of London. He started
coding at the age of eight and has programmed all kinds of computers, from single-chip
microcontrollers to world-class supercomputers. His many projects include giant space
simulations, research in high-tech companies, and intelligent robots made from junk.
Jon has a passion for science and technology education, giving talks on space and running
computer programming clubs in schools. He has worked on many science and technology
books, and is coauthor of DK’s Help Your Kids with Computer Coding and author of DK’s
Coding Games in Scratch, and DK’s series of coding workbooks.
Contents
8 foreword
12 Creative computers
82 Birthday Card
14 Programming languages
94 Spiralizer
16 How Scratch works
106 Fantastic Flowers
18 Getting Scratch
20 The Scratch interface
22 Types of projects
In recent years, interest in coding has exploded. All over the world, schools
are adding coding to their curriculums, code clubs are being launched to
teach beginners, and adults are returning to college to learn coding skills
now considered vital in the workplace. And in homes everywhere, millions
of people are learning how to code just for the fun of it.
Fortunately, there’s never been a better time to learn how to code. In the
past, programmers had to type out every line of code by hand, using obscure
commands and mathematical symbols. A single period out of place could
ruin everything. Today, you can build amazingly powerful programs in
minutes by using drag-and-drop coding languages like Scratch™, which
is used in this book.
As learning to code has become easier, more people have discovered the
creative potential of computers, and that’s where this book comes in. Coding
Projects in Scratch is all about using code for creative purposes—to make
art, music, animation, and special effects. With a little bit of imagination
you can produce dazzling results, from glittering fireworks displays to
kaleidoscope-like masterpieces that swirl and beat in time to music.
If you’re completely new to coding, don’t worry—the first two chapters
will walk you through the basics and teach you everything you need to
know to use Scratch. The later chapters then build on your skills, showing
you how to create interactive artworks, lifelike simulations, mind-bending
optical illusions, and some great games.
Learning something new can sometimes feel like hard work, but I believe
you learn faster when you’re having fun. This book is based on that idea,
so we’ve tried to make it as much fun as possible. We hope you enjoy
building the projects in this book as much as we enjoyed making them.
On your mark...
get set... CODE!
What is
coding?
12 w h at i s c o d i n g ?
Creative computers
Computers are everywhere and are used in all sorts of
creative ways. But to really join in the fun, you need to
take control of your computer and learn how to program it.
Programming puts a world of possibilities at your fingertips.
▷ A simple recipe
Imagine you want a friend to bake a cake, but your
Easy peasy!
friend has no idea how to cook. You can’t simply give
an instruction like “make a cake”—your friend won’t
know where to start. Instead, you need to write a
recipe, with simple steps like “break an egg,” “add
the sugar,” and so on. Programming a computer Recipe
is a bit like writing a recipe.
Recipe
Ingredients
2. Seven colors
◁ Step by step Instructions
Now imagine you want to 1. Clear the screen to create a white background.
program a computer to create
2. Repeat the following ten times:
a painting like the one shown
here, with colored circles a) Pick a random place on the screen.
overlapping each other at b) Pick one of the circles randomly.
random. You have to turn the c) Pick one of the colors randomly.
job of painting the picture into
d) Draw a see-through copy of the circle
a kind of recipe, with steps the at that place in that color.
computer can follow. It might
look something like this:
c r e at i v e c o m p u t e r s 13
▷ Computer language
Although you can understand the recipe when clicked
for a painting or a cake, a computer can’t.
forever
You need to translate the instructions into
move 10 steps
a special language that the computer can
understand—a programming language.
The one used in this book is called Scratch.
Worlds of imagination
There isn’t a single creative field in the world that hasn’t been touched
by computers. In this book, you’ll get to make lots of great projects that
will fire your imagination and make you think and code creatively.
Building games programs is just as much fun as Special effects and dramatic scenery in movies
playing them, especially when you make all the rules. are often created in graphics programs.
14 W H AT I S C O D I N G ?
Programming languages
To tell a computer what to do, you need to speak the right
kind of language: a programming language. There are lots
to choose from, ranging from easy ones for beginners, like
the one in this book, to complex languages that take years
to master. A set of instructions written in any programming
language is called a program.
scratch
Popular languages
There are more than 500 different
Hello!
programming languages, but most programs
are written in just a handful of these. The
most popular languages use English words,
but lines of code look very different from
English sentences. Here’s how to get a
computer to say “Hello!” on screen in
just a few of today’s languages.
▷C
The C programming language #include <stdio.h>
is often used for code that main(){ printf(“Hello!”); } Hello!
runs directly on a computer’s
hardware, such as the Windows
operating system. C is good for
building software that needs to
run fast, and has been used
to program space probes.
#include <iostream>
▷ C++ int main()
This complicated language is used {
to build large, commercial programs std::cout << “Hello!” << std::endl;
such as word processors, web }
browsers, and operating systems.
C++ is based on C, but with extra
features that make it better for
big projects.
PROGRAMMING LANGUAGES 15
class HelloApp {
when clicked public static void main(String[] args) {
say Hello! System.out.println(“Hello!”);
}
}
△ Scratch
Beginners often start with simple programming
languages such as Scratch. Instead of typing out △ Java
code, you build scripts with ready-made blocks of code. Java code is designed to work on all types
of devices, from cell phones and laptops
to games consoles and supercomputers.
Minecraft is written in Java.
print(“Hello!”)
lingo
Code words
Algorithm A set of instructions that
are followed to perform a particular
task. Computer programs are based
on algorithms.
△ Python Bug A mistake in a program. They are
Python is a very popular, all-purpose language. called bugs because the first computers
The lines of code are shorter and simpler than had problems when insects got stuck in
in other languages, making it easier to learn. their circuits.
Python is a great language to learn after Scratch.
Code Computer instructions written in
a programming language are often called
code. Coding is programming.
alert(‘Hello’);
△ JavaScript
Programmers use JavaScript to create
interactive features that run on websites,
such as advertisements and games.
16 w h at i s c o d i n g ?
Sprites
Sprites are the objects shown on the screen. Scratch comes with
a huge selection of sprites—such as elephants, bananas, and
balloons—but you can also draw your own. Sprites can perform all
sorts of actions, like moving, changing color, and spinning around.
I’m a sprite!
wait 1 secs
wait 1 secs
Online Offline
Visit the Scratch website at http:// Visit the Scratch website at http://
scratch.mit.edu and click on “Join scratch.mit.edu/scratch2download/
Scratch” to create an account with and follow the instructions to download
a username and password. You’ll and install Scratch on your computer.
need an email address too.
Online Scratch runs in your web browser, Scratch will appear as an icon on
so just go to the Scratch website and your desktop, just like any other
click on “Create” at the top of the screen. installed program. Double-click
The Scratch interface will open. on the Scratch cat icon to get going.
You don’t have to worry about saving You’ll need to save your project by
your work because the online version clicking on the File menu and selecting
of Scratch saves projects automatically. “Save”. Scratch will ask you where
to save your work—check with the
computer’s owner.
when clicked
forever
move 10 steps
go to mouse-pointer ▾
turn 15 degrees
point in direction 90 ▾
point towards ▾
go to x: 0 y: 0
go to mouse-pointer ▾
glide 1 secs to x: 0 y: 0
Motion Events
Looks Control
when clicked
Sound Sensing hide
x: -126
y: 96
Pen Operators repeat 300
move 10 steps
◁ Scratch 2.0
turn 15 degrees
go to Rocket ▾
point towards ▾
go to x: 0 y: 0
point in direction
show
pick random –180 to 180 are many more blocks and features than
x: 153 y: -61
go to mouse pointer ▾
repeat 50
Stage hide
1 backdrop
New backdrop:
Rocket Stars
can save scripts, sprites, and other
Backpack
useful things.
ExpErt tips
Mouse-pointers
Scratch needs some accurate something with your computer
mouse-work, which is easier to mouse. If your mouse only has
do with a computer mouse than one button, you can hold down
a touchpad. In this book, you’ll the shift or control key on your
often be instructed to right-click keyboard as you click.
20 w h at i s c o d i n g ?
interface
This is Scratch mission control. SCRATCH File ▾ Edit ▾ Tips ?
The Stage
This is where the action
happens. When you run your
project, the stage is where all
the sprites appear, moving
and interacting as they
follow their scripts.
x: 153 y: -61
Stage
SPrIteS 1 backdrop Dinosaur1 Dinosaur2 Dinosaur3 Ballerina
lISt New backdrop:
S ta g e I n f o B a C K Pa C K
Scripts area
Use the Drag blocks into this part of the
Select the Costumes tab Use the Sounds tab to Scratch window and join them
Scripts tab to to change how add music and sound together to build scripts for each
build scripts. sprites look. effects to sprites. sprite in your project.
Motion Events
Looks Control Click these headings Selected
to reveal different sprite
x: 20
Sound Sensing sets of blocks. y: –100
Pen Operators
Data More Blocks
when clicked
forever
move 10 steps
repeat 3
Backpack
Types of projects
This book has a wide range of fun Scratch projects. Don’t
worry if you haven’t used Scratch before or you’re not an
expert—the “Getting started” chapter is there to help
you. Here’s a handy guide to the projects in this book.
48 g e t t i n g s ta r t e d animal race 49
60 g e t t i n g s ta r t e d ask gobo 61
◁ Variables
The cat’s script stores
Cat Art (p.26) Dino Dance Party (p.34) Animal Race (p.48) Ask Gobo (p.60)
information in something
3 programmers call a variable.
In this project, you’ll use
a variable to store the The dog runs for
numbers for the cat’s count the finish – one stride
at the start of the race. The cross and arrow every time you press
Count mark the start line. the “m” key.
△ Getting started
Work your way through these easy projects to learn how to
use Scratch. Each project introduces important new ideas, so
don’t skip any if you’re a beginner. By the end of the chapter,
you’ll have mastered the basics of Scratch.
94 a
arrt
t s
spp ii r
raal
l ii z
zeer
r 95 Funny Faces (p.70)
t Spiralizer b i r t h d ay c a r d 83
Try
Try out
out this
this spinning
spinning spiral
spiral project.
project.
day Card
Click
Click the
the icon
icon to The
to The
The clones’
clones’ different
different The ball
ball in
in the
the centre
centre
Be sure to run this project
Change
Change the
A balloon-filled backdrop the patterns
patterns using
The animatedusing
special
special
sign at the
make
make the
fill
the spiral
spiral directions
directions make
make is
is the
the original
original sprite;
sprite;
fill your
your screen.
screen. them
them form
form aa spiral. all
all the
the others
others are
are clones.
in full-screen mode. sets the scene. sliders
sliders to
to alter
altertopthe
rocksvalues
the values of variables
ofside.
from side to variables spiral. clones.
n ordinary birthday in
in the
the code.
code. You
You control
control the the artart –– the
the Spiralizer
ou can have an Birthday Card possibilities
possibilities are
are endless!
endless! Spiralizer
by SpiralAttack (unshared)
by SpiralAttack (unshared)
ast for the eyes and by PartyPlanner120 (unshared)
◁ Art
Y!
BIRTHDA
ging sharks, but you How
How it
it works
works Speed
Speed 22 △ Clones
△ Clones
Clones
e project to make Clones are
are working
working copies
copies
This
This simple
simple project
project has
has only
only one
one sprite:
sprite: aa of
of sprites.
sprites. When
When aa clone
clone isis
HAPPY
coloured created,
created, it
it appears
appears on
on top
coloured ball,
ball, which
which stays
stays in
in the
the middle.
middle. This project uses the “glide” of
top
Scratch’s of the
the existing
existing sprite
sprite and
and
Scratch’s clone
clone blocks
blocks make
make copies
copies of
of the
the block, which makes sprites has
has the
the same
same properties,
properties,
ball
ball that
that move
move outwards
outwards in in straight
straight lines.
lines. move smoothly around such
such as
as direction,
direction, size,
size,
the stage. You need to use
rks A
A spiral
spiral pattern
pattern forms
forms because
because each
each clone
clone Scratch’s coordinates system
and
and so
so on.
on.
moves
moves inin aa slightly
slightly different
different direction,
direction, like
Window Cleaner
Each
Each line
line is
is drawn
drawn using
(unshared)
Scratch’s
Scratch’s built-in
which
which lets
lets any
any sprite
using
built-in pen,
pen,
sprite draw.
draw.
△ Scratch
△ Scratch pen pen Slime tim
Slime tim
LY ON YOUR BIRTHDAY! Every
Every sprite
sprite can
can draw
draw aa
To make som
How
How it
it works
works
with flowers.
The game starts by cloning a splat sprite and scattering ▽ Splat sprite
The game starts by cloning a splat sprite and scattering ▽ Splat sprite
22
This game has one sprite The pain
clones with different costumes randomly across the stage. This game has one sprite The pain
clones with different costumes randomly across the stage. with several costumes, make yo
make yo
When motion is detected by the webcam, Scratch uses with several costumes, a colour
When motion is detected by the webcam, Scratch uses which you’ll paint yourself. a colour
122 123 its “ghost” effect to make the splats fade. If you wave your which you’ll paint yourself.
By cloning the sprite you
122 games
games
tunnel of doom
tunnel of doom 123 its “ghost” effect to make the splats fade. If you wave your By cloning the sprite you
hand enough, they eventually disappear. The aim of the can cover the screen with
hand enough, they eventually disappear. The aim of the can cover the screen with
Tunnel of Doom Do you dare
Do you dare
to enter the
to enter the
“Tunnel of Doom”?
game is to remove as many splats as you can in one minute.
game is to remove as many splats as you can in one minute.
splats of messy gunk.
splats of messy gunk.
Scratch is
Scratch is the
the ideal
ideal playground
playground forfor making
making and
and Will your time “Tunnel of Doom”?
Will your time
perfecting games.
games. To
To win
win at
at this
this game,
game, you
you need
need The cat starts here. Time in seconds be the fastest?
perfecting
33 Select th
The cat starts here. Time in seconds be the fastest?
a steady
a steady hand
hand and
and nerves
nerves of
of steel.
steel. Take
Take the
the cat
cat Select th
and dra
all the
all the way
way through
through the
the Tunnel
Tunnel ofof Doom,
Doom, but
but and dra
Tunnel of Doom Window Cleaner of a larg
don’t
don’t touch
touch the
the walls!
walls! For
For an
an extra
extra challenge,
challenge, Tunnel of Doom
by DirtDigger465 (unshared) Window Cleaner of a larg
by PaintChampion (unshared) whole p
▷ Games
try to
try to beat
beat the
the best
best time.
time. by DirtDigger465 (unshared)
by PaintChampion (unshared) whole p
Time
Time
201
201 will get
Score 42 will get
Best time
Best time
245
245 Score 42
How it
How it works
works Reach home to
Reach home to
win the game. Countdown 8
Use your mouse
mouse toto move
move thethe cat
cat all
all the
the way
way through
through
win the game. Countdown 8
Use your
Drumtastic
190 music and sound Dancing cat
To make the project more fun, the cat will dance and
d r u m ta s t i c 191
A,B,C,D...
chapter shows you how to simulate falling snow, sparkling background symbol
to in the each variable.
When you run the project, the Scratch cat asks you to into a drum sound. There are lower Stage
a solid colour by left of Scratch,
▽ Scratch26 drumkit
letters in the alphabet but
How it works
type something in the box. When you press return, the Scratch
The script turns onlyletter
every has 18 drum
clicking thepicking
paint a cool 2 backdrops Click here to make
Make a Variable
each variable.
Click here.
The words The drums light up Click “OK” to Choose this option.
◁ Mindbenders
Making images move in clever ways can fool
the eye into seeing amazing patterns and
optical illusions. Try these mindbending,
spinning-pattern projects.
exPert tiPs
Perfect projects
Every project in this book is do, go back a few steps and check
broken down into easy steps— the instructions again carefully.
read each step carefully and you’ll If you still have problems, ask
sail through them all. The projects an adult to check with you. Once
tend to get more complicated you’ve got a project working,
later in the book. If you find a don’t be afraid to change the
project isn’t doing what it should code and try out your own ideas.
Getting
started
26 g e t t i n g s ta r t e d
How it works
This simple project lets you use a
computer mouse to paint multicolored
cat art. Wherever you drag the mouse, a
rainbow trail of cats is left behind. Later
on you’ll see how to add other effects.
◁ Artistic cat
This project lets you go wild
with your imagination. You
can experiment with a variety
of colors, sizes, and effects
for the cat, and in the end
your project will look like
a piece of modern art.
Mouse control
The first step is to make the cat sprite move wherever
the mouse-pointer moves. You need to build a set of Follow me.
Motion Events
Looks Control
The cat sprite on the Sound Sensing x: -126
y: 96
stage is the only item Pen
Data
Operators
More Blocks
in a new project.
move 10 steps
turn 15 degrees
turn 15 degrees
when clicked
point in direction 90 ▾
forever
point towards ▾
go to mouse-pointer ▾
go to x: 0 y: 0
x: 153 y: -61
go to mouse-pointer ▾
Sprites New sprite:
glide 1 secs to x: 0 y: 0
change x by 10
Backpack
forever
Stops scripts
Starts scripts
Multicolored cats
Scratch is packed full of ways to make
art. The simple script changes here will
send your cat straight to the art gallery.
go to mouse-pointer ▾
go to mouse-pointer ▾
12 You’ll find that the stage soon fills up with cats, but
don’t worry, because you can add a script to wipe when space ▾ key pressed
it clean at the press of a button. Choose Pen in the
blocks palette and look for the “clear” block. Drag it clear
into the scripts area but keep it separate from the
first script. Then click on Events and add a brown
“when space key pressed” block. Run the project This header block starts the
and see what happens when you press the space bar. script when the chosen key is
pressed on the keyboard.
ExpErt tips
Full screen
To see projects at their
best, you can simply click
the full-screen button just
above the stage to hide
the scripts and just show
the results. There’s a similar
button to shrink the stage
and reveal the scripts again
from full-screen mode.
Click here to
If you use the offline
see your project
version of Scratch, don’t
fill the screen.
forget to save your work
from time to time.
32 g e t t i n g s ta r t e d
▽ Smooth changes
Don’t be afraid to experiment with the numbers and settings
in Scratch commands. You don’t have to change the cat’s
when clicked
color effect by 25 each time. The lower the number, the more
slowly the color will change, like in this rainbow. forever
go to mouse-pointer ▾
stamp
ExpErt tips
Scratch's ghost effect Script runs from The “forever” block makes
makes sprites transparent. top to bottom. the program return to the
start of the loop.
when clicked
forever
when left arrow ▾ key pressed
change color ▾ effect by 25
change ghost ▾ effect by –1
34 g e t t i n g s ta r t e d
How it works
Each sprite has one or more scripts
that program its dance moves. Some
simply turn from side to side, but
others glide across the dance floor
or perform more varied moves. You
can add as many dancers as you like.
◁ Dinosaur
After you’ve created a dancing
dinosaur, you can duplicate
this sprite to make a group of
dinosaurs dancing in rhythm.
The “spotlight-stage”
backdrop sets the scene
for the dance party.
◁ Ballerina
To add a touch of class, the
ballerina will perform a more
complicated dance routine.
dino dance party 35
By switching between
different poses, the
sprites appear to dance.
Let’s party!
36 g e t t i n g s ta r t e d
Dancing dinosaur
Scratch has lots of ready-made sprites for your project in the
sprite library. Many of the sprites have several “costumes”,
each showing the sprite in a different pose. If you make
a sprite switch costumes quickly, it looks like it’s moving.
New
?
Revert
duplicate
delete
Dinosaur1
save to local file
dino dance party 37
5 Look at the dinosaur on the stage and press the space-bar. Every time
you press it, the dinosaur will change its pose. It’s still the Dinosaur1
Each pose is a different
costume belonging to
sprite, but the way it looks keeps changing. Each different pose is called the dinosaur sprite.
a costume and can be used to make a sprite appear to do different things.
2
Each costume has a
different name.
dinosaur1-b
233x158
Vector Mode
Convert to bitmap
dinosaur1-d
95x172
38 g e t t i n g s ta r t e d
Dance steps
By using loops you can make the dinosaur change
its costume repeatedly, making it appear to move.
Changing pictures quickly to give the illusion of
movement is called animation.
when clicked
forever
Remember, blocks are
next costume color-coded. The “forever”
loop is in the yellow
Control blocks section.
dinosaur1-c dinosaur1-d
Choose
“dinosaur1-d”.
dino dance party 39
Right-click
delete
Choose “duplicate”
(or shift/ctrl-click) to make a copy of the
save to local file
on the dinosaur. sprite and its scripts.
The “spotlight-stage”
Stage backdrop sets the
1 backdrop Dinosaur1 mood of the party.
New backdrop:
15 Add this script to make the disco lights flash. This block only
Then click the green flag to run the project— changes the backdrop
when clicked colors. It does not
it should look like a real disco. You can
affect the other sprites.
experiment with the time in the “wait”
forever
block to make the lights flash faster or
slower if you want. change color ▾ effect by 25
Dinosaur1 Dinosaur2
if on edge, bounce
Add this block to turn
Dinosaur2
the dinosaur round at
the stage’s edge.
Dinosaur2
x: –5 y: 18 direction: -90°
rotation style:
can drag in player:
show:
42 g e t t i n g s ta r t e d
Keyboard control
Ever dreamed of taking control of your very own
dinosaur? The next script will give you keyboard
control of Dinosaur3’s movements: you’ll be able
to move the dinosaur across the stage with the
right and left arrow keys.
complicated, so make
sure you get everything forever key right arrow ▾ pressed?
in the right place. The
“if then” block is in if then
the yellow Control Drag this pale blue Sensing
block into the window in
blocks section. It’s a point in direction 90 ▾ the yellow block.
special block that
chooses whether or move 10 steps Choose 90 here. This points
not to run the blocks the sprite to the right.
inside it by asking a
question. Take care to
ensure that both “if if key left arrow ▾ pressed? then
then” blocks are inside
the “forever” loop and point in direction –90 ▾ Click here and choose
not inside each other. “left arrow”.
move 10 steps
25 Before you run the script, read through it carefully and see
if you can understand how it works. If the right arrow key
is pressed, blocks that make the sprite point right and move
are run. If the left arrow key is pressed, blocks that make
the sprite point left and move are run. If neither is pressed,
no blocks are run and the dinosaur stays put. Repeat step
22 to stop Dinosaur3 from turning upside down.
dino dance party 43
ExpErt tips
Making choices
You make choices all the time. If you’re hungry, you
decide to eat; if not, you don’t. Computer programs
can also make choices between different options.
One way to make them do this is to use an “if then”
instruction, which is used in lots of programming Is the right
arrow key Move right
languages. In Scratch, the “if then” block includes
pressed? Yes
a statement or a question and only runs the code (true)
inside the block if the statement is true (or the
answer is yes).
No
(false)
Add a ballerina
The dinosaurs are dancing, but it’s not much of a party
without some friends. A ballerina is going to join the fun
and will do a routine. Her scripts will show you how to
create more complicated dance routines.
26 Click on the sprite symbol in the sprites list and load the
ballerina. Then use your mouse to drag the sprite to a good
spot on the stage. To give the ballerina some scripts, make
sure she’s selected in the sprites list—the selected sprite
has a blue outline. Scripts Costumes Sounds
Ballerina
ballerina-a
61x10
lingo
Algorithms
An algorithm is a series ALGORITHM PROGRAM
of simple, step-by-step (Dance steps) (Dance steps turned into computer
instructions that together programming language)
carry out a particular task.
In this project, we converted
STAND!
the ballerina’s dance
routine (an algorithm) into WAIT! switch costume to ballerina-a ▾
a program. Every computer
program has an algorithm wait 0.5 secs
at its heart. Programming is
KICK! switch costume to ballerina-d ▾
translating the steps of the
algorithm into a computer wait 0.5 secs
WAIT!
programming language that
the computer understands. switch costume to ballerina-a ▾
STAND! wait 0.5 secs
BEND
THE KNEES!
dino dance party 45
ExpErt tips
repeat loops and forever loops
Look at the bottom of the two types of forever repeat 10
loop you’ve used so far. Which one can
have blocks attached to it? You might
notice that the “repeat” block has a small
lug on the bottom, but the “forever” block
doesn’t. There’s no lug on a “forever” loop
because it goes on forever, so there’s no
point adding blocks after it. A “repeat”
block, however, runs a fixed number A lug allows you to
of times and the script then continues. join new blocks.
forever
Animal Race
Have you ever wondered which is
faster—a dog or a bat? Now you Animal Race
by TopDog763 (unshared)
can find out when you play this
fun fast-finger, button-pressing,
two-player animal race game. Go!
How it works
The aim of this two-player game is simply
to race across the screen and reach the
balloons before the other player. Fast
finger action is all you need to win.
The faster you tap the keyboard’s “z”
or “m” key, the faster your sprite moves
from left to right.
◁ Sending messages
This project shows you how
to use Scratch’s message
feature to make one sprite
pass information to other
sprites, such as when the
cat sprite tells the dog
and bat to start racing.
◁ Variables
The cat’s script stores
information in something
3 programmers call a variable.
In this project, you’ll use
a variable to store the
numbers for the cat’s count
at the start of the race. The cross and arrow
Count mark the start line.
Another Random Document on
Scribd Without Any Related Topics
"Well?" repeated the Inspector-General, biting the ends of his
close-cropped moustache. "What more did you expect, sir? Naturally
the man's own people were not going to give him away. They nearly
did so, though. You heard what old Zewar Pasha said?"
"Tut! I take no account of that," said the Sirdar. "The brothers of
Christ Himself would have put Him down, too—locked Him up in an
asylum, I dare say."
"That's exactly what I would do with Ishmael Ameer, anyway,"
said the Inspector-General. "Of course he performs no miracles, and
is attended by no angels. His removal to Torah, and his inability to
free himself from a Government jail, would soon dispel the belief in
his supernatural agencies."
"But how can we do it? Under what pretext? We can't imprison
a man for preaching the second coming of Christ. If we did, our jails
would be pretty full at home, I'm thinking."
The Inspector-General laughed. "Your old error, dear Sirdar. You
can't apply the same principles to East and West."
"And your old Parliamentary cant, dear friend! I'm sick to death
of it."
There was a moment of strained silence, and then the
Inspector-General said—
"Ah well, I know these holy men, with their sham inspirations
and their so-called heavenly messages. They develop by degrees, sir.
This one has begun by proclaiming the advent of the Lord Jesus,
and he will end by hoisting a flag and claiming to be the Lord Jesus
himself."
"When he does that, Colonel, we'll consider our position afresh.
Meantime it may do us no mischief to remember that if the family of
Jesus could have dealt with the founder of our own religion as you
would deal with this olive-faced Arab there would probably be no
Christianity in the world to-day."
The Inspector-General shrugged his shoulders and rose to go.
"Good-night, sir."
"Good-night, Colonel," said the Sirdar, and then he sat down to
draft a dispatch to the Consul-General—
"Nothing to report since the marriage, betrothal, or whatever it
was, of the 'Rani' to the man in question. Undoubtedly he is laying a
strong hold on the imagination of the natives and acquiring the
allegiance of large bodies of workers; but I cannot connect him with
any conspiracy to persuade people not to pay taxes or with any
organised scheme that is frankly hostile to the continuance of British
rule.
"Will continue to watch him, but find myself at fearful odds
owing to difference of faith. It is one of the disadvantages of
Christian Governments among people of alien race and religion, that
methods of revolt are not always visible to the naked eye, and God
knows what is going on in the sealed chambers of the mosque.
"That only shows the danger of curtailing the liberty of the
vernacular press, whatever the violence of its sporadic and muddled
anarchy. Leave the press alone, I say. Instead of chloroforming it
into silence give it a tonic if need be, or you drive your trouble
underground. Such is the common sense and practical wisdom of
how to deal with sedition in a Mohammedan country, let some of the
logger-headed dunces who write leading articles in England say what
they will.
"If this man should develop supernatural pretensions I shall
know what to do. But without that, whether he claim divine
inspiration or not, if his people should come to regard him as divine,
the very name and idea of his divinity may become a danger, and I
suppose I shall have to put him under arrest."
Then remembering that he was addressing not only the Consul-
General but a friend, the Sirdar wrote—
"'Art Thou a King?' Strange that the question of Pontius Pilate is
precisely what we may find in our own mouths soon! And stranger
still, almost ludicrous, even farcical and hideously ironical, that
though for two thousand years Christendom has been spitting on the
pusillanimity of the old pagan, the representative of a Christian
Empire will have to do precisely what he did.
"Short of Pilate's situation, though, I see no right to take this
man, so I am not taking him. Sorry to tell you so, but I cannot help
it.
"Our love from both to both. Trust Janet is feeling better. No
news of our poor boy, I suppose?"
"Our boy" had for thirty years been another name for Gordon.
CHAPTER XV
At the second bar the old lady joined him in her breaking, cracking
voice, and the Consul-General, albeit his throat was choking him,
forced himself to sing with her—
"When the soft dews of kindly sleep
My wearied eyelids gently steep..."
The light of another world was in the old lady's eyes when all was
over, and she seemed to be already half way to heaven.
CHAPTER XVI
All the same there was a sweet humanity left in her, and when the
Chaplain was gone and the side-table had been cleared, and she
was left alone with her old husband, there came little gleams of the
woman who wanted to be loved to the last.
"How are you now?" he asked.
"Better so much better," she said, smiling upon him, and
caressing with her wrinkled hand the other wrinkled hand that lay on
the eider-down quilt.
The great Consul-General, sitting on the chair by the side of the
bed, felt as helpless as before, as ignorant as ever of what millions
of simple people know—how to talk to those they love when the
wings of Death are hovering over them. But the sweet old lady, with
the wisdom and the courage which God gives to His own on the
verge of eternity, began to speak in a lively and natural voice of the
end that was coming and what was to follow it.
He was not to allow any of his arrangements to be interfered
with, and, above all, the festivities appointed for the King's Birthday
were not to be disturbed.
"They must be necessary or you would not have them,
especially now," she said, "and I shall not be happy if I know that on
my account they are not coming off."
And then, with the sweet childishness which the feebleness of
illness brings, she talked of the last King's Birthday, and of the ball
they had given in honour of it.
That had been in their own house, and the dancing had been in
the drawing-room, and the Consul-General had told Ibrahim to set
the big green arm-chair for her in the alcove, and sitting there she
had seen everything. What a spectacle! Ministers Plenipotentiary,
Egyptian Ministers, ladies, soldiers! Such gorgeous uniforms! Such
glittering orders! Such beautiful toilets!
The old lady's pale face filled with light as she thought of all
this, but the Consul-General dropped his head, for he knew well
what was coming next.
"And, John, don't you remember? Gordon was there that night,
and Helena—dear Helena! How lovely they looked! Among all those
lovely people, dear.... He was wearing every one of his medals that
night, you know. So tall, so brave-looking, a soldier every inch of
him, and such a perfect English gentleman! Was there ever anything
in the world so beautiful? And Helena, too! She wore a silvery silk,
and a kind of coif on her beautiful black hair. Oh, she was the
loveliest thing in all the room, I thought! And when they led the
cotillion—don't you remember they led the cotillion, dear?—I could
have cried, I was so proud of them."
The Consul-General continued to sit with his head down,
listening to the old lady and saying nothing, yet seeing the scene as
she depicted it and feeling again the tingling pride which he, too,
had felt that night but permitted nobody to know.
After a moment the beaming face on the bed became clouded
over, as if that memory had brought other memories less easy to
bear—dreams of happy days to come, of honours and of children.
"Ah well, God knows best," she said in a tremulous voice,
releasing the Consul-General's hand.
The old man felt as if he would have to hurry out of the room
without uttering another word, but, as well as he could, he
controlled himself and said—
"You are agitating yourself, Janet. You must lie quiet now."
"Yes, I must lie quiet now, and think of ... of other things," she
answered.
He was stepping away when she called on him to turn her on
her right side, for that was how she always slept, and upon the
Egyptian nurse coming hurrying up to help, she said—
"No, no, not you, Fatimah—his lordship."
Then the Consul-General put his arms about her—feeling how
thin and wasted she was, and how little of her was left to die—and
turning her gently round he laid her back on the pillow which
Fatimah had in the meantime shaken out.
While he did so her dim eyes brightened again, and stretching
her white hands out of her silk nightdress she clasped them about
his neck, with the last tender efforts of the woman who wanted to
be fondled to the end.
The strain of talking had been too much for her, and after a few
minutes she sank into a restless doze, in which the perspiration
broke out on her forehead and her face acquired an expression of
pain, for sleep knows no pretences. But at length her features
became more composed and her breathing more regular, and then
the Consul-General, who had been standing aside, mute with
anguish, said in a low tone to Fatimah—
"She is sleeping quietly now," and then he turned to go.
Fatimah followed him to the head of the stairs and said in a
husky whisper—
"It will be all over to-night, though—you'll see it will."
For a moment he looked steadfastly into the woman's eyes, and
then, without answering her, walked heavily down the stairs.
Back in the library, he stood for some time with his face to the
empty fireplace. Over the mantelpiece there hung a little picture, in
a black-and-gilt frame, of a bright-faced boy in an Arab fez. It was
more than he could do to look at that portrait now, so he took it off
its nail and laid it, face down, on the marble mantel-shelf.
Just at that moment one of his secretaries brought in a
despatch. It was the despatch from the Sirdar, sent in cypher but
now written out at length. The Consul-General read it without any
apparent emotion and put it aside without a word.
The hours passed slowly; the night was very long; the old man
did not go to bed. Not for the first time, he was asking himself
searching questions about the mystery of life and death, but the
great enigma was still baffling him. Could it be possible that while he
had occupied himself with the mere shows and semblance of things,
calling them by great names—Civilisation and Progress—that simple
soul upstairs had been grasping the eternal realities?
There were questions that cut deeper even than that, and now
they faced him one by one. Was it true that he had married merely
in the hope of having some one to carry on his name and thus fulfil
the aspirations of his pride? Had he for nearly forty years locked his
heart away from the woman who had been starving for his love, and
was it only by the loss of the son who was to have been the crown
of his life that they were brought together in the end?
Thus the hoofs of the dark hours beat heavily on the great
Proconsul's brain, and in the awful light that came to him from an
open grave, the triumphs of the life behind him looked poor and
small.
But meantime the palpitating air of the room upstairs was full of
a different spirit. The old lady had apparently awakened from her
restless sleep, for she had opened her eyes and was talking in a
bright and happy voice. Her cheeks were tinged with the glow of
health, and her whole face was filled with light.
"I knew I should see them," she said.
"See whom, my heart?" asked Fatimah, but without answering
her, the old lady, with the same rapturous expression, went on
talking.
"I knew I should, and I have! I have seen both of them!"
"Whom have you seen, my lady?" asked Fatimah again, but
once more the dying woman paid no heed to her.
"I saw them as plainly as I see you now, dear. It was in a place
I did not know. The sun was so hot, and the room was so close.
There was a rush roof and divans all round the walls. But Gordon
and Helena were there together, sitting at opposite sides of a table
and holding each other's hands."
"Allah! Allah!" muttered Fatimah, with upraised hands.
The old lady seemed to hear her, for an indulgent smile passed
over her radiant face and she said in a tone of tender remonstrance
—
"Don't be foolish, Fatimah! Of course I saw him. The Lord said I
should, and He never breaks His promises. 'Help me, O God, for
Christ's sake,' I said. 'Shall I see my dear son again? O God, give me
a sign.' And He did! Yes, it was in the middle of the night. 'Janet,'
said a voice, and I was not afraid. 'Be patient, Janet. You shall see
your dear boy before you die.'"
Her face was full of happy visions. The life of this world seemed
to be no longer there. A kind of life from the other world appeared
to reanimate the sinking woman. The near approach of eternity
illumined her whole being with a supernatural light. She was dying in
a flood of joy.
"Oh, how good the Lord is! It is so easy to go now! ... John, you
must not think I suffer any longer, because I don't. I have no pain
now, dear—none whatever."
Then she clasped her wasted hands together in the attitude of
prayer and said in a rustling whisper—
"To-night, Lord Jesus! Let it be to-night!"
After that her rapturous voice died away and her ecstatic eyes
gently closed, but an ineffable smile continued to play on her faintly-
tinted face, as if she were looking on the wings that were waiting to
bear her away.
The doctor came in at that moment, and was told what had
occurred.
"Delirium, of course," he said. A change had come; the crisis
was approaching. If the same thing happened at the supreme
moment the patient was not to be contradicted; her delusion was to
be indulged.
It did not happen.
In the early hours of the morning the Consul-General was called
upstairs. There was a deep silence in the bedroom, as if the air had
suddenly become empty and void. The day was breaking, and
through the windows that looked over to the Nile the white sails of a
line of boats gliding by seemed like the passing of angels' wings.
Sparrows were twittering in the eaves, and through the windows to
the east the first streamers of the sunrise were rising in the sky.
The Consul-General approached the bed and looked down at
the pallid face on the pillow. He wanted to stoop and kiss it, but he
felt as if it would be a profanation to do so now. His own face was
full of suffering, for the sealed chambers of his iron soul had been
broken open at last.
With his hands clasped behind his back he stood for some
minutes quite motionless. Then laying one hand on the brass head-
rail of the bed, he leaned over his dead wife and spoke to her as if
she could hear.
"Forgive me, Janet! Forgive me!" he said in a low voice that was
like a sob.
Did she hear him? Who can say she did not? Was it only a ray
from the sunrise that made the Egyptian woman think that over the
dead face of the careworn and weary one, whose sweet soul was
even then winging its way to heaven, there passed the light of a
loving smile?
CHAPTER XVII
CHAPTER XVIII
Five days after the death of Lady Nuneham the Consul-General was
reading at his breakfast the last copy of the Times to arrive in Cairo.
It contained an anticipatory announcement of a forthcoming
Mansion House Banquet in honour of the King's Birthday. The
Foreign Minister was expected to speak on the "unrest in the East,
with special reference to the affair of El Azhar."
The Consul-General's face frowned darkly, and he began to
picture the scene as it would occur. The gilded hall, the crowd of
distinguished persons eating in public, the mixed odours of many
dishes, the pop of champagne corks, the smoke of cigars, the buzz
of chatter like the gobbling of geese on a green, and then the
Minister, with his hand on his heart, uttering timorous apologies for
his Proconsul's policy, and pouring out pompous platitudes as if he
had newly discovered the Decalogue.
The Consul-General's gorge rose at the thought. Oh, when
would these people, who stayed comfortably at home and lived by
the votes of the factory-hands of Lancashire and Yorkshire, and
hungered for the shouts of the mob, understand the position of men
like himself, who, in foreign lands, among alien races, encompassed
by secret conspiracies, were spending their strength in holding high
the banner of Empire?
"Having chosen a good man, why can't they leave him alone?"
thought the Consul-General.
And then, his personal feelings getting the better of his
patriotism, he almost wished that the charlatan element in Ishmael
Ameer might develop speedily; that he might draw off the allegiance
of the native soldiers in the Soudan and break out, like the Mahdi,
into open rebellion. That would bring the Secretary of State to his
senses, make him realise a real danger, and see in the everlasting
"affair of El Azhar" if not light, then lightning.
The door of the breakfast-room opened and Ibrahim entered.
"Well, what is it?" demanded the Consul-General with a frown.
Ibrahim answered in some confusion that a small boy was in the
hall, asking to see the English lord. He said he brought an urgent
message, but would not tell what it was or where it came from. Had
been there three times before, slept last night on the ground outside
the gate, and could not be driven away—would his lordship see the
lad?
"What is his race? Egyptian?"
"Nubian, my lord."
"Ever seen the boy before?"
"No ... yes ... that is to say ... well, now that your lordship
mentions it, I think ... yes I think he came here once with Miss Hel
... I mean General Graves's daughter."
"Bring him up immediately," said the Consul-General.
At the next moment a black boy stepped boldly into the room. It
was Mosie. His clothes were dirty, and his pudgy face was like a
block of dark soap splashed with stale lather, but his eyes were clear
and alert and his manner was eager.
"Well, my boy, what do you want?" asked the Consul-General.
Mosie looked fearlessly up into the stern face with its iron jaw,
and tipped his black thumb over his shoulder to where Ibrahim, in
his gorgeous green caftan, stood timidly behind him.
At a sign from the Consul-General, the Egyptian servant left the
room, and then, quick as light, Mosie slipped off his sandal, ripped
open its inner sole, and plucked out a letter stained with grease.
It was the letter which Helena had written in Khartoum.
The Consul-General read it rapidly, with an eagerness which
even he could not conceal. So great, indeed, was his excitement that
he did not see that a second paper (Ishmael's letter to the
Chancellor of El Azhar) had fallen to the floor until Mosie picked it up
and held it out to him.
"Good boy," said the Consul-General—the cloud had passed and
his face bore an expression of joy.
Instantly apprehending the dim purport of Helena's hasty letter,
the Consul-General saw that what he had predicted and half hoped
for was already coming to pass. It was to be open conspiracy now,
not passive conspiracy any longer. The man Ishmael was falling a
victim to the most fatal of all mental maladies. The Mahdist delusion
was taking possession of him, and he was throwing himself into the
Government's hands.
Hurriedly ringing his bell, the Consul-General committed Mosie
to Ibrahim's care, whereupon the small black boy, in his soiled
clothes, with his dirty face and hands, strutted out of the room in
front of the Egyptian servant, looking as proud as a peacock and
feeling like sixteen feet tall. Then the Consul-General called for one
of his secretaries and sent him for the Commandant of Police.
The Commandant came in hot haste. He was a big and rather
corpulent Englishman, wearing a blue-braided uniform and a fez—
naturally a blusterous person with his own people, but as soft-voiced
as a woman and as obsequious as a slave before his chief.
"Draw up your chair, Commandant—closer; now listen," said the
Consul-General.
And then in a low tone he repeated what he had already
learned from Helena's letter, and added what he had instantly
divined from it—that Ishmael Ameer was to return to Cairo; that he
was to come back in the disguise of a Bedouin Sheikh; that his
object was to draw off the allegiance of the Egyptian army in order
that a vast horde of his followers might take possession of the city;
that this was to be done during the period of the forthcoming
festivities, while the British army was still in the provinces, and that
the conspiracy was to reach its treacherous climax on the night of
the King's Birthday.
The Commandant listened with a gloomy face, and, looking
timidly into the flashing eyes before him, he asked if his Excellency
could rely on the source of his information.
"Absolutely! Infallibly!" said the Consul-General.
"Then," said the Commandant nervously, "I presume the
festivities must be postponed?"
"Certainly not, sir."
"Or perhaps your Excellency intends to have the British army
called back to Cairo?"
"Not that either."
"At least you will arrest the 'Bedouin'?"
"Not yet at all events."
The policy to be pursued was to be something quite different.
Everything was to go on as usual. Sports, golf, cricket, croquet,
tennis-tournaments, polo-matches, race-meetings, automobile-
meetings, "all the usual fooleries and frivolities"—with crowds of
sight-seers, men in flannels and ladies in beautiful toilets—were to
be encouraged to proceed. The police-bands were to play in the
public gardens, the squares, the streets, everywhere.
"Say nothing to anybody. Give no sign of any kind. Let the
conspiracy go on as if we knew nothing about it. But——"
"Yes, my lord? Yes?"
"Keep an eye on the 'Bedouin.' Let every train that arrives at the
railway-station and every boat that comes down the river be
watched. As soon as you have spotted your man, see where he
goes. He may be a fanatical fool, miscalculating his 'divine' influence
with the native soldier, but he cannot be working alone. Therefore
find out who visit him, learn all their movements, let their plans
come to a head, and, when the proper time arrives, in one hour, at
one blow we will crush their conspiracy and clap our hands upon the
whole of them."
"Splendid! An inspiration, my lord!"
"I've always said it would some day be necessary to forge a
special weapon to meet special needs, and the time has come to
forge it. Meantime undertake nothing hurriedly. Make no mistakes,
and see that your men make none."
"Certainly, my lord."
"Investigate every detail for yourself, and above all hold your
tongue and guard your information with inviolable secrecy."
"Surely, my lord."
"You can go now. I'm busy. Good-morning!"
"Wonderful man!" thought the Commandant, as he went out at
the porch. "Seems to have taken a new lease of life! Wonderful!"
The Consul-General spent the whole of that day in thinking out
his scheme for a "special weapon," and when night came and he
went upstairs—through the great echoing house that was like the
bureau of a department of state now, being so empty and so
cheerless, and past the dark and silent room whereof the door was
always closed—he felt conscious of a firmer and lighter step than he
had known for years.
Fatimah was in his bedroom, for she had constituted herself his
own nurse since his wife's death. She was nailing up on the wall the
picture of the little boy in the Arab fez, and, having her own theory
about why he had taken it down in the library, she said—
"There! It will be company for your lordship, and nobody will
ask questions about it here."
When Fatimah had gone the Consul-General could not but think
of Gordon. He always thought of him at that hour of the night, and
the picture of his son that rose in his mind's eye was always the
same. It was a picture of Gordon's deadly white face with its
trembling lower lip, as he stood bolt upright while his medals were
being torn from his breast, and then said, in that voice which his
father could never forget: "General, the time may come when it will
be even more painful to you to remember all this than it has been to
me to bear it."
Oh, that Gordon could be here now and see for himself what a
sorry charlatan, what a self-deceived quack and conspirator, was the
man in whose defence he had allowed his own valuable life to rush
down to a confused welter of wreck and ruin!
As the Consul-General got into bed he was thinking of Helena.
What a glorious, courageous, resourceful woman she was! It carried
his mind back to Biblical days to find anything equal to her daring
and her success. But what was the price she had paid for them? He
remembered something the Sirdar had said of "a marriage, a sort of
betrothal," and then he recalled the words of her first letter: "I know
exactly how far I intend to go, and I shall go no farther. I know
exactly what I intend to do, and I shall do it without fear or
remorse."
What had happened in the Soudan? What was happening there
now? In what battle-whirlwind had that splendid girl's magnificent
victory been won?
CHAPTER XIX
ebookball.com