Circle
Wars
74 C I R C L E W A R S The timer shows The score rises or
how long each falls as green and red
How to build game takes. clones are touched
Circle Wars by the player.
Circle Wars
Lightning reactions are essential
in Circle Wars, a fast-paced game in by HappyShrimp321 (unshared)
which you hunt green circles while
being chased by red ones. The Score 8
game uses Scratch’s clones feature,
which can turn a single sprite into Time 23.5
an army of sinister copies.
The solid green circle lays
AIM OF THE GAME the friendly clones.
Move the blue circle around the screen
using the mouse. Collect the pale green
circles, but avoid the red ones that march
toward you like a zombie army. The solid
green and solid red circles drop clones of
themselves as they roam around. Score
more than 20 points to win and go below
–20 to lose.
◁ Player
The player is the blue circle.
If you don’t keep moving
quickly, the enemy circles
will soon overwhelm you.
◁ Friends
The friendly circles are green.
When you touch one, you
score a point and the circle
disappears with a pop.
◁ Enemies
Steer clear of the red enemy
circles. Touch one and it takes
three points off your score, before
vanishing with a clash of cymbals.
HOW TO BUILD CIRCLE WARS 75
The solid red circle lays Click the green flag Click the stop sign GAME CONTROLS
the enemy clones. to start a new game. to end a game.
Use a computer mouse
or touchpad to control
this game.
Player It’s all my
own work!
◁ Is it art?
Not all games use cartoon
sprites. With its colored
circles, this game looks more
like a piece of modern art.
Once you’ve built it, why not
make up a story to explain
the game. You can change
the sprites, colors, and
backdrop to tell that story.
Don’t let them
get you!
Clones of the solid red Clones of the solid green
circle chase the player. circle chase the player.
76 C I R C L E W A R S
Creating the sprites
First you need to create the three sprites for
the main game. These are all simple colored
circles, so you can draw them yourself. Start
by following these instructions to create the
player’s character—the blue circle.
Player Friend Enemy
circle circle circle
1 Start a new project and name it 2 To draw a blue
“Circle Wars”. Click the paintbrush circle, first select
symbol at the top of the sprites “Bitmap Mode”
list to paint a new sprite. (bottom right).
Then choose
New sprite: blue in the
color palette.
Click here to paint Circle tool
a new sprite.
3 Click the circle tool on the left 4 While holding down the shift
and then select a solid color key (this gives you a circle
(rather than an outline) at the rather than an oval), click with
bottom left of the paint editor. the mouse and drag to draw
a circle. The circle should be
Select solid color. about the size of the cat’s
head. When you’re happy with
the circle’s size, delete the cat
sprite (right-click on it and
select “delete”).
Look on the stage to compare the
size of your new sprite to the cat.
EXPERT TIPS
Resizing the circle
5 You now need to center If your circle is too big
the sprite. Select the “Set
costume center” tool (top or too small, you can
right) and then click in the
very center of the circle. change the size of it Grow
Rename the sprite “Player” by selecting either the
by clicking on the blue “i”
in the sprites list. “Grow” or “Shrink” tool
on the bar along the top
of the Scratch screen, Shrink
then clicking on the circle.
GAME PROGRESS 2 0 % 77
Making friends and enemies Selecting
“duplicate”
You can now make the green friend and red makes a copy
enemy circles. You can use other colors if you like, of the sprite.
but make sure you can easily tell the three
different circles apart. info
Player duplicate
6 Start by right-clicking on the Player sprite and selecting
“duplicate”. Do this twice. You’ll now have three blue circles. delete
Rename Player2 as “Friends” and Player3 as “Enemies”.
7 Select the Friends sprite and click the “Fill with
Costumes tab. Choose green in the color” tool
color palette. Select the “Fill with color”
tool and click inside the blue circle to
make it turn green.
8 Repeat the steps Sprites I have some friends Click inside the
for the Enemies and quite a few blue circle to
sprite, but color Player enemies! make it green.
this sprite red. You
should now have Friends Enemies
three different
colored sprites.
Instant player control 10 Add the script below to get the blue circle
following the mouse. Read it through and
Now add a score display and a script to make make sure you understand what it does.
the Player sprite stick to the mouse-pointer— Run the script to check it works. The red
just like in Star Hunter. and green circles won’t do anything yet.
9 Select the Player sprite, click Data, and make a variable when clicked
called “Score” for all sprites. Then put a check in the
variable’s box to show “Score” on the stage.
set Score ▾ to 0
New Variable Checking this box forever
Variable name: Score ensures that the
score will appear
on the stage. go to mouse-pointer ▾
For all sprites For this sprite only
OK Cancel Score This block “glues” the Player sprite
to the mouse-pointer.
78 C I R C L E W A R S
March of the clones We’re all We’re all We’re all
different! different! different!
From just two sprites—the green and
red circles—you can create an army I’m not!
of friends and enemies to pursue the
player’s blue circle. You can do this
through the magic of cloning. Before
you create your clones, first get the
Friends sprite moving randomly
around the stage.
when clicked Picks random
forever direction
11 Select the green Friends sprite.
Add this script to make the point in direction pick random –180 to 180
circle bounce around the stage
with a random change of repeat 25
direction every 250 steps.
move 10 steps
if on edge, bounce
12 Run the project and The “repeat” loop
watch the green circle’s runs the blocks
unpredictable journey. The inside it 25 times.
Friends sprite moves 250
steps in 10-step jumps but it EXPERT TIPS
doesn’t get stuck to the walls.
After 250 steps, the “forever” Repeat loops
loop goes back to the start.
The sprite changes direction You’ve already seen The blocks inside
randomly and sets off again. “forever” loops that repeat 4 times.
repeat a group of blocks
Random direction nonstop. A “repeat” loop when clicked
changes happen does a similar job, but it
every 250 steps. only repeats the blocks pen down
inside a fixed number of
times. This type of loop repeat 4
is sometimes called a
“for” loop, because it move 100 steps
repeats for a certain
number of times. The turn 90 degrees
example shown here
repeats an action four pen up After 4 repeats, the
times to draw a square. next block is run.
GAME PROGRESS 4 0 % 79
Making clones when clicked
Now we’re going to make our forever
friendly clone army. These are
the clones you need to catch point in direction pick random –180 to 180
to score points.
repeat 25
13 Add a “create clone of myself”
block as the last block in the move 10 steps Drag this block into
“forever” loop. You’ll find it in if on edge, bounce the bottom of the
the yellow Control section. “forever” loop.
This block will create a clone
of the Friends sprite after create clone of myself ▾
each 250-step movement.
A new clone is
created every
250 steps.
14 Run the project. At each change of
direction, the sprite leaves a copy
of itself—a clone. The clones aren’t
just pictures—they are fully working
copies of the original sprite, and you
can give them their own instructions.
15 New clones are controlled by a special All clones run their own This block makes
script that starts with the block “when copy of this script. all the clones
I start as a clone”. Add the script below transparent.
to the Friends sprite. The script tells when I start as a clone
each clone to move toward the Player
sprite for 300 steps, after which the set ghost ▾ effect to 50
clone is deleted and vanishes from the
stage. The clones move one step at a repeat 300 The instructions
time. They move more slowly than the point towards Player ▾ within the block
original Friends sprite, which moves move 1 steps are repeated
in 10-step jumps. 300 times.
delete this clone
16 Run the script and watch the green The clone moves slowly
clones advance slowly toward the toward the Player sprite
Player sprite. Don’t worry—they’re in 1-step jumps.
the good guys!
The clone disappears
after 300 steps.
80 C I R C L E W A R S
Destroying clones when I start as a clone Make sure the
set ghost ▾ effect to 50 “if then” block is inside
The last part of the script for repeat 300
the Friends clone checks if the the “repeat” loop.
clone is touching the Player. point towards Player ▾
If it is, the clone gets deleted. move 1 steps then
17 Add an “if then” block if touching Player ▾ ?
containing the blocks shown change Score ▾ by 1
here to check whether the play sound pop ▾
clone is touching the Player delete this clone
sprite after each move. Try
running the project now—the
score should increase as you
touch green circles, which
instantly disappear with a pop.
POP! When the Player sprite touches
the clone, the clone is destroyed.
EXPERT TIPS
delete this clone
Clones
Clones are useful any time you want lots of Such languages are called “object oriented”
copies of a sprite. Many programming languages and include Java and C++. In Scratch,
languages let you make copies of things, but there are three orange blocks that control
they are often called objects rather than clones. clones, all found in the Control section.
create clone of myself ▾ delete this clone
△ This block creates a clone of the sprite. The clone △ This block gets rid of the clone. All clones
is identical to the sprite and appears in the same disappear from the stage when a project stops,
position and facing the same direction, so you leaving just the original sprite.
won’t be able to see it until it moves.
when I start as a clone
△ When a clone starts, it runs the script headed with
this block. Clones don’t run the sprite’s main script,
but they can run all other scripts in the sprite’s scripts
area, such as scripts triggered by messages.
GAME PROGRESS 6 0 % 81
Enemy clones
Now you need to add scripts to the Enemies sprite
to make it produce clones that chase the Player.
You can do this by copying the scripts from the
Friends sprite across to the Enemies sprite.
18 To copy scripts, just click, drag, and Sprites Release the mouse
drop scripts from one sprite onto when the mouse-
another. Drag the two scripts you pointer is over the
made for the Friends sprite onto the red circle.
Enemies sprite, one at a time. This
makes copies of the scripts in the Player Friends when clicked
Enemies sprite. forever
19 Select the Enemies sprite. The The “clean up” point in direction pick random –180 to 180
scripts you dragged and dropped option reveals repeat 25
will probably be on top of one any hidden scripts.
another, because any copied script move 10 steps
just appears at the top left of the
scripts area. To rearrange them, if on edge, bounce
right-click on the background and
select “clean up”. clean up create clone of myself ▾
add comment
20 Now adjust the Enemies clone change Score ▾ by –3 This reduces the player’s
script so that it takes points away score by 3 points.
when the Player touches a red clone.
Alter the “change Score by” block so Change the script to
it changes the score by –3 instead of play a cymbal sound.
+1. You really want to avoid those
nasty red enemies! She may not be the
best player, but she is
21 Add a sound to tell the player that play sound cymbal ▾
points have been lost. Load the the loudest!
cymbal sound into the Enemies
sprite by selecting “cymbal” in the
sound library. Alter the script to play
“cymbal”, not ”pop”. You’ll now hear
which type of clone you’ve touched.
22 Run the project. Check that you
now have both red and green
clones, and that touching a red
clone takes 3 points off your score.
82 C I R C L E W A R S
Win or lose? when clicked This block sets the score
to 0 at the start.
You’ve created two ever-expanding set Score ▾ to 0
clone armies: one of friendly circles that You can find this
help you win points, and one of evil forever block in the green
circles that make you lose points. Next Operators section.
you need to add the code that tells you go to mouse-pointer ▾
if you’ve won or lost the game. then
if Score > 20
23 Add the new “if then” blocks shown here These blocks run
to the Player sprite. They check your score. think Victory! when the score
If the score is greater than 20, you win, and stop this script ▾ is more than 20.
a thought bubble with the word “Victory!”
appears. If the score is less than –20, you
lose, and the sprite thinks “Defeat!”
Victory! Defeat! if Score < –20 then
think Defeat! These blocks run
stop this script ▾ when the score
is less than –20.
Score 21 Score –21 The Player sprite stops
following the mouse-pointer
when either the winning or
losing score is reached.
LINGO When we add these to “if then” blocks, they create
statements that are either true or false. In Circle
Comparison operators Wars, the “is more than” operator tells you that
you’ve won the game when you score over 20.
Earlier we saw how you can use “if then” blocks
to create true or false statements—also known if Score > 20 then
as Boolean expressions—that lead to different
outcomes. For example, in Star Hunter, “if
touching cat then play sound fairydust” makes
a sound play only when the cat gets a star. We
can do the same thing with numbers by using
what are called comparison operators:
2<5 3=3 5>1 think Victory!
is less than equals is more than stop this script ▾
GAME PROGRESS 80% 83
24 Run the game. Try to touch only the green I am the
circles. Check that the game ends when the champion!
key scores are reached, and check that the
Player sprite thinks “Victory!” or “Defeat!”You
can reduce the score needed to win if you find
it too difficult. But don’t make the game too
easy—Circle Wars is meant to be a challenge!
Adding a timer when clicked
To add some competition to the set Score ▾ to 0
game, you can include an on-screen
timer that shows players how long reset timer This block starts the
they take to complete a game. timing from 0.
25 Click on the Data section and make a forever
variable “Time” for all sprites. To show
it on the stage, check the box next to go to mouse-pointer ▾
the variable’s block. Select the Player
sprite. Click on Sensing in the blocks if Score > 20 then
palette. Add “reset timer” to the Player’s
script, just before the “forever” loop. Go think Victory!
back to Data and drag a “set Time to” stop this script ▾
block to the script and add “timer” to it,
making it the last instruction in the if Score < –20 then
forever loop.
26 By copying “timer” to the variable think Defeat!
“Time”, each trip around the loop will stop this script ▾
now display the time on the stage. But
the moment the player wins or loses, set Time ▾ to timer
the time stops being updated (the
script is stopped) and the total time
it took to win or lose is shown.
Time 41.573 I think it must be This block updates
lunch time! the Time display
Total number every time the
of seconds loop repeats.
in the game
84 C I R C L E W A R S Use black Choosing a light background color
for the text. will make the text easier to read.
Instructions
You may want to decorate your
Players need to know the rules of the instructions with colored circles.
game. Create a special sprite that shows
the instructions for Circle Wars when
the game begins.
27 Use the paintbrush symbol to create a new
sprite and rename it “Instructions”. Select
“Bitmap Mode” and choose a color. Select the
“Fill with color” tool and click on the drawing
area to fill it with your chosen color.
“Fill with color” tool
28 Now select black from the palette as the You are the blue circle.
color for the text. Then choose the text tool Move using the mouse.
and type out the instructions shown here. Be quick!
Text tool Try to touch the friendly green circles.
Each one gives you 1 point.
29 If the text doesn’t fit, use the select tool to Avoid the enemy red circles.
resize it by pulling the corner points in or Each one you touch takes 3 points.
out. When you’ve finished, click outside the
box around the text to stop editing. Score more than 20 to win.
Score less than –20 and you lose.
“Select” tool
Press the space bar to start!
GAME DESIGN
Game stories
Computer games usually have a story to explain why the
action in the game is happening. At the moment, Circle
Wars has no story. Can you make one up? It could be a
battle in space, with a blue spaceship saving friendly
green spaceships and trying to avoid being hit by the red
enemy craft. Let your imagination run riot! Including
some of the story in your instructions will help make the
game more interesting and exciting for the player.
GAME PROGRESS 100% 85
30 Add this script to the sprite Did someone
to show the instructions mention space?
on the stage at the start of
the game. Read it carefully. when clicked
Can you see how it works?
go to x 0 y: 0
These blocks show the instructions
in the center of the screen in front go to front
of other sprites. show
This block hides the Instruction wait until key space ▾ pressed?
sprite when the player presses
the space bar to start playing.
hide
31 You also need to add when clicked
a “wait until key space
pressed” block immediately wait until key space ▾ pressed?
after the green flag blocks
in the Player, Friends, and set Score ▾ to 0 Add a “wait until key
Enemies sprites’ scripts. This reset timer space pressed” block
will hold back all the action forever to the scripts of all
until the space bar is pressed. three sprites.
go to mouse-pointer ▾
32 Run the project and your then
instructions should appear, if Score > 20
filling the screen until you
press the space bar. Players will think Victory!
have plenty of time to read and stop this script ▾
understand the instructions,
letting them start the game
when they’re ready.
if Score < –20 then
I’m ready think Defeat!
to play! stop this script ▾
set Time ▾ to timer
86 C I R C L E W A R S
Hacks and tweaks
You’ve got Circle Wars working—well done! △ Find a balance
Now to personalize it and make it your own.
Try these suggestions and your own ideas. Experiment with different speeds, or change
Once you’ve created something unique, why how many points you win or lose for touching
not share it on the Scratch projects website? Friends and Enemies. It’s not difficult to make
the game very hard or very easy, but can you
▽ What’s the story? find a balance to make it just the right level?
Did you think of a story to explain what’s going on in
Circle Wars? Maybe it’s the attack of the dragons, and
the princess player has to eat cakes to survive? Add
some scenery and music to the game to fit with that
story. Experiment with different stories and looks.
▷ The war’s over! GAME
OVER!
Add a broadcast message to
reveal a “Game over!” sprite when
the player wins or loses, like you
did in Cheese Chase. You can
change the text of the “Game
over!” sprite so that it relates to
your story about the game.
▷ Slow down, blue! go to mouse-pointer ▾ Add the “point towards”
block and an instruction
To make things tricky, change Remove the to “move 5 steps”.
the blue circle’s script so that it “go to” block.
no longer “sticks” to the mouse point towards mouse pointer ▾
pointer but chases slowly after
it. You could also invent simple move 5 steps
keyboard controls for the sprite.
▽ Tweak the timer That’s their best
The number in the timer flickers because it shows lots of time yet!
decimal places. To round the value so it shows only whole
seconds, use the green “round” block near the bottom of
the Operators section. Try adding a “Best time” for winning
players, just as you added a “High score” in Cheese Chase.
set Time ▾ to round timer
HACKS AND TWEAKS 87
▽ Change the colors Green and
blue circles
Vary the clones’ colors. Click on the Friends sprite. Add are friends.
the “set color effect to” block from the Looks section to
the sprite’s clone script. Then drag “pick random” from
Operators into the block’s window and change the
values to –30 and 30. Do the same for the Enemies
sprite. New clones will now have different colors!
when I start as a clone pick random –30 to 30 Orange, yellow,
set color ▾ effect to pink, and purple
set ghost ▾ effect to 50 Insert this instruction immediately circles are enemies.
repeat 300 after “when I start as a clone”.
▷ Change the size From green
Operators section
Add the “change size by” block to
the scripts of both the Friends and when I start as a clone
Enemies sprites to make each clone
a random size. Alter the scoring so change size by pick random –30 to 30
that the size of the circle you touch
determines how many points you set ghost ▾ effect to 50 Change the values
score. You’ll also need to change repeat 300 to “–30” and “30”.
the totals needed to win or lose. Try
more than 2,000 points for victory, Change the Friends’
and less than –2,000 for defeat. score value to this.
change Score ▾ by size
change Score ▾ by 0 – size
Use this The bigger the clone, the more
scoring for points you win or lose.
Enemies.
◁ Shape shifting
Introduce another shape into the game.
It could be a square that eats red circles,
a triangle that runs away from the player,
a hexagon that makes the player shrink
or grow, or anything else you want to try.