0% found this document useful (0 votes)
252 views31 pages

Grow A Dragonfly

The document provides instructions for creating a Scratch project where players control a dragonfly sprite to eat insect sprites. The dragonfly grows larger each time it eats an insect. The project involves setting up the scene with backdrops and sprites, editing sounds to create wing flapping, making insects bounce around and hide when eaten, and using random positioning and delays to continually spawn new insects for the dragonfly to eat. The goal is to have the dragonfly continually grow in size as it eats more insects.

Uploaded by

api-652369770
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
0% found this document useful (0 votes)
252 views31 pages

Grow A Dragonfly

The document provides instructions for creating a Scratch project where players control a dragonfly sprite to eat insect sprites. The dragonfly grows larger each time it eats an insect. The project involves setting up the scene with backdrops and sprites, editing sounds to create wing flapping, making insects bounce around and hide when eaten, and using random positioning and delays to continually spawn new insects for the dragonfly to eat. The goal is to have the dragonfly continually grow in size as it eats more insects.

Uploaded by

api-652369770
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/ 31

27/05/2022, 12:01 Grow a dragonfly

Projects

Grow a dragonfly
Make a dragonfly that grows bigger as it eats
annoying mosquitos and other insects.

Step 1 Introduction

Make a nature app with a dragonfly that grows bigger as it eats insects.
You will:
Use if blocks to make decisions based on conditions made with operators and sensing blocks
Use random numbers to control the movement of a sprite
Use the Sounds editor to edit a sound

We use conditions all the time to make decisions. We could say “if the pencil is blunt, then sharpen it”. If
blocks and conditions let us write code that does something different depending on whether a condition is
true or false.

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 1/31
27/05/2022, 12:01 Grow a dragonfly

Step 2 Set the scene

You will set the scene. Choose your backdrop and add a
dragonfly that follows the mouse-pointer around the Stage.

Open the Grow a dragonfly starter project (https://scratch.mit.edu/projects/535695413/editor).


Scratch will open in another browser tab.

Working offline
For information about how to set up Scratch for offline use, visit our ‘Getting started with Scratch’
guide (https://projects.raspberrypi.org/en/projects/getting-started-scratch/1).

Dragonflies can be found all over the world and have been around for over 300 million years!

Choose: Click Choose a Backdrop and add a backdrop of your choice. We used the Jurassic backdrop.

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 2/31
27/05/2022, 12:01 Grow a dragonfly

Click Choose a Sprite and search for dragonfly, then add the Dragonfly sprite.

Add a script to make the Dragonfly sprite follow the mouse-pointer (or your finger):

when clicked

set size to 25 % to start small

forever

point towards mouse-pointer

move 5 steps

Test: Click the green flag and make the Dragonfly sprite move around the Stage. Is the dragonfly
moving as you would expect?

The Dragonfly costume is not facing to the right, so the head of the Dragonfly sprite is not pointing towards the
mouse-pointer.

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 3/31
27/05/2022, 12:01 Grow a dragonfly

Click on the Costumes tab and use the Select (arrow) tool to select the costume. Use the Rotate tool at
bottom of the selected costume to turn the Dragonfly costume to face the right.

Test: Click the green flag and look at how the dragonfly moves now.

Dragonfly wings make a fluttering sound as they vibrate. You can edit a sound in Scratch to create your own sound.

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 4/31
27/05/2022, 12:01 Grow a dragonfly

Add the Crank sound to the Dragonfly sprite.

Adding a sound from the library


Select the sprite you want to add the sound to.

Click the Sounds tab, and click Choose a Sound:

Sounds are organised by category, and you can hover over the icon to hear a sound. Choose a
suitable sound.

You should then see that your sprite has your chosen sound.

Click the Play button so you can hear the sound.

The Crank sound is too long and too slow for dragonfly wings.

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 5/31
27/05/2022, 12:01 Grow a dragonfly

Select the end of the sound using your cursor or finger.


Click Copy to New to make a new sound with just the selected part:

Rename your new sound from Crank2 to Wings.

Play the new sound. Click the Faster button a few times until you like the result:

If you like, you can select the very end of the Wings sound, and then click Delete to remove it:

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 6/31
27/05/2022, 12:01 Grow a dragonfly

Now add a block to play the Wings sound when the dragonfly moves:

when clicked

set size to 25 %

forever

start sound Wings

point towards mouse-pointer

move 5 steps

Test: Try out your dragonfly movement and sound effect.

Save your project

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 7/31
27/05/2022, 12:01 Grow a dragonfly

Step 3 A fly to eat

You will add an insect for the dragonfly to eat.

Characters that move around on their own in games are sometimes called mobs, short for mobiles. Can you
think of a game that has mobs?

There’s a fly in the Frog 2 sprite that you can use.

Add the Frog 2 sprite to your project. Rename the sprite to Insect:

You only need the fly, not the frog.

Click on the Costumes tab. Click on the fly to select it and click on the Copy icon.

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 8/31
27/05/2022, 12:01 Grow a dragonfly

Add a new costume to the sprite using the Paint option:

Click on the Paste icon to paste the sprite into the new costume. Drag the fly to the centre so it lines up
with the crosshair.

You can rename your costume Insect and delete the other costumes, as you won’t need those:

Increase the size of the fly so that it’s easier to see and catch:

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 9/31
27/05/2022, 12:01 Grow a dragonfly

Click on the Code tab and add a script to make the Insect sprite bounce around:

when clicked

forever

move 3 steps

if on edge, bounce

The if on edge, bounce block checks to see if the sprite has reached the edge of the Stage and
points the sprite in a different direction if it has.

You want the Insect sprite to hide if it gets eaten by the Dragonfly sprite.

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 10/31
27/05/2022, 12:01 Grow a dragonfly

Add an if block to the Insect sprite’s movement script:

when clicked

forever

move 3 steps

if on edge, bounce

if then

The if has a hexagon-shaped input. This means you can put a condition here.

When the if block runs, Scratch will check the condition. If the condition is ‘true’ then the code inside the if
block will run.
You want the insect to hide if it is touching the Dragonfly sprite.

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 11/31
27/05/2022, 12:01 Grow a dragonfly

Drag a touching [Dragonfly v] into the if block. Add a hide block inside the if block.

when clicked

forever

move 3 steps

if on edge, bounce

if touching Dragonfly ? then change from 'mouse-pointer'

hide eaten

Test: Test your code and control the dragonfly to eat the fly. The fly should disappear.

The dragonfly won’t get very big if it can only eat one fly!

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 12/31
27/05/2022, 12:01 Grow a dragonfly

Add blocks to go to a random position on the Stage, and make your sprite wait for one second
then show:

when clicked

show show at the start

forever

move 3 steps

if on edge, bounce

if touching Dragonfly ? then

hide

go to random position

wait 1 seconds

show to look like a new fly

Test: Test that your dragonfly can now eat lots of flies.
Make sure you have added the show block to show at the start.

Tip: You can click the red Stop button above the Stage if you want the dragonfly to be quiet while you add more
code.

Save your project

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 13/31
27/05/2022, 12:01 Grow a dragonfly

Step 4 Grow to full-size

You will make the dragonfly grow when it eats a fly, and stop
if it reaches full-size.

The biggest living dragonflies can be found in Central America and have a wingspan of 19cm (a bit bigger
than your hand). The largest insect ever known was Meganeuropsis permiana, a dragonfly with a wingspan
of about 75cm (the size of a big footstep).

The fly knows that it has been eaten, and now the Dragonfly needs to know so that it grows.
When you need to let another sprite know that something has happened, you can use a broadcast block as you
did in Broadcasting spells (https://projects.raspberrypi.org/en/projects/broadcasting-spells).

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 14/31
27/05/2022, 12:01 Grow a dragonfly

Add a broadcast block to the Insect sprite with new message food:

when clicked

show show at the start

forever

move 3 steps

if on edge, bounce

if touching Dragonfly ? then

broadcast food

hide

go to random position

wait 1 seconds

show

The Dragonfly sprite needs to grow when it receives the food message.

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 15/31
27/05/2022, 12:01 Grow a dragonfly

Select the Dragonfly sprite and add this script:

when I receive food

change size by 5

Add the Chomp sound to the dragonfly and start it when an insect gets eaten:

when I receive food

start sound Chomp

change size by 5

Test: Run your project to test the dragonfly grows and makes a chomp sound when it eats a fly.

When the dragonfly reaches its full size, the game will congratulate you and stop.

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 16/31
27/05/2022, 12:01 Grow a dragonfly

Add an if block.

The dragonfly is full-size when the size = 100%. First, add an = operator into the hexagon-shaped
input:

when I receive food

start sound Chomp

change size by 5

if = then

Finish building the condition by adding a built-in size variable and type the value 100:

when I receive food

start sound Chomp

change size by 5

if size = 100 then

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 17/31
27/05/2022, 12:01 Grow a dragonfly

Add blocks so that if the condition is true then the dragonfly will broadcast an ‘end’ message and
say I got to full size!

Finally, add a stop all block to stop the other dragonfly scripts:

when I receive food

start sound Chomp

change size by 5

if size = 100 then

broadcast end

say I got to full size!

stop other scripts in sprite change from 'all'

At the moment, the fly still moves after the project has ended. Add this script to the Insect sprite.

when I receive end

stop other scripts in sprite

Test: Click the green flag and keep eating flies until your dragonfly reaches full-size.

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 18/31
27/05/2022, 12:01 Grow a dragonfly

Save your project

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 19/31
27/05/2022, 12:01 Grow a dragonfly

Step 5 Improved movement

The dragonfly ‘glitches’ and changes direction really fast if


the mouse-pointer is touching the dragonfly. You will check
another condition to fix this.

Select the Dragonfly and find the script that starts with when flag clicked.

Drag an if inside the forever block and the blocks inside the forever will move inside the if.

Check carefully that your code looks like this:

when clicked

set size to 25 %

forever

if then

start sound Wings

point towards mouse-pointer

move 5 steps

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 20/31
27/05/2022, 12:01 Grow a dragonfly

Then drag a not block into the if and a touching (mouse-pointer) inside that.

Check that your code looks like this:

when clicked

set size to 25 %

forever

if not touching mouse-pointer ? then

start sound Wings

point towards mouse-pointer

move 5 steps

The not block turns a condition into its opposite, just like it would in a sentence.

Test: Check that the glitch is fixed, and the Dragonfly only moves when it is not touching (mouse-
pointer).

A different condition to try is:

distance to mouse-pointer > 50

This makes the dragonfly move when it’s far enough from the mouse-pointer.
Tip: You can drag blocks anywhere in the Code area and leave them there while you try different things.

Save your project

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 21/31
27/05/2022, 12:01 Grow a dragonfly

Step 6 More food

The dragonfly needs a choice of insects.

Right-click on the Insect sprite in the Sprite list under the Stage and duplicate it.

It’s helpful if this insect looks different to the fly.

Click on the Costumes tab.


Choose: Create a different flying insect.
Use the Fill tool to change the colour of this insect
Paint your own insect costume
Add another bug costume from Scratch

The insect gets eaten even if it touches the dragonfly’s wing or tail.
To make your app more realistic, fix this so that the insect gets eaten by the dragonfly’s mouth. You can use the
touching color block so the insect only gets eaten if it is touches a particular colour on the Dragonfly.

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 22/31
27/05/2022, 12:01 Grow a dragonfly

Select the Dragonfly sprite and click on the Costumes tab.


Use the fill tool to fill in the Dragonfly’s mouth. We used purple:

You need to check that the Insect2 sprite is touching the Dragonfly sprite and touching the colour of the
dragonfly’s mouth.

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 23/31
27/05/2022, 12:01 Grow a dragonfly

Select the Insect2 sprite and click on the Code tab.


Drag an and block into the if block.

The <touching [Dragonfly v] ?> block will pop out, drag it into the left of the and block:

when clicked

show

forever

move 3 steps

if on edge, bounce

if touching Dragonfly ? and then

broadcast food

hide

go to random position

show

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 24/31
27/05/2022, 12:01 Grow a dragonfly

Drag a touching color block into the right of the and block:

when clicked

show

forever

move 3 steps

if on edge, bounce

if touching Dragonfly ? and touching color ? then

broadcast food

hide

go to random position

show

If it doesn’t have the colour of the dragonfly’s mouth selected, click on the colour circle and then click on
the Eyedropper tool to select a colour.

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 25/31
27/05/2022, 12:01 Grow a dragonfly

Click on the dragonfly’s mouth on the Stage to set the colour to match:

Tip: If this is tricky to do, change the size of the Dragonfly sprite so it’s really big.

Test: Now test that the dragonfly can only eat the second insect with its mouth.
If you like, you can change the first Insect so that it can only be eaten with the dragonfly’s mouth.

Save your project

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 26/31
27/05/2022, 12:01 Grow a dragonfly

Step 7 Random insect movement

The insects in your app move in a very predictable pattern,


but in real life they are hard to catch.
You will use the pick random block to make the insect
move in a more natural way.

Add a script to Insect 2 to make it point in a random direction every 1–3 seconds.

when clicked

forever Keep changing direction

point in direction pick random 0 to 259

wait pick random 1 to 3 seconds

Test: Run your project and watch how the fly moves. Try changing the numbers to get the effect you
want.

You can also drag this script to the Insect sprite so that it also moves randomly.

Change the insects until they behave the way you want them to.
You could change the number of steps they move to make them faster or slower.

You could also change the speed of the dragonfly.

You could also change the size that the dragonfly needs to grow to reach full size.
Make changes until you are happy with your project.

Save your project

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 27/31
27/05/2022, 12:01 Grow a dragonfly

Upgrade your project


In this step, try adding more insects, changing the way your
project looks and behaves.

Add more insects


Add more insects. You might need to make them move faster, so they are harder for the dragonfly to catch.
You can paint your own insects or trying adding an emoji mosquito!

Use the emoji keyboard to add a Mosquito emoji sprite.


Duplicate an existing insect sprite then click on the Costumes tab. Paint a new costume and select the
Text tool. Instead of typing text, use the emoji keyboard shortcut for your Operating System:
Windows - Windows key + ‘.’
MacOS - ctrl + cmd + space
Linux - ctrl + ‘.’

Select the Mosquito emoji to insert it into the Paint editor. Use the Select (arrow) tool to centre, resize,
and rotate your mosquito until you are happy with it.

Tip: Emojis can look different on different computers, so they might not look the same on a tablet and a
desktop computer. Some emojis aren’t available on some computers, but most modern computers will
support them.

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 28/31
27/05/2022, 12:01 Grow a dragonfly

Use your Backpack to trade insects with your friends from their ‘Grow a Dragonfly’ projects.

Using the Scratch Backpack


You can use your Scratch Backpack to store costumes, sprites, sounds, and scripts that you want
to copy between projects.
You can only access your own Backpack, and you must be logged in to your Scratch account to
use it.
To open your Backpack, click on the Backpack tab at the bottom of the screen.

To add a sprite to your Backpack, drag the sprite from the Sprite list to the Backpack. This will
store the full sprite in your Backpack, including all of its costumes, sounds, and scripts.

To add a backdrop to your Backpack, select the Stage pane and click on the Backdrops tab, then
choose the backdrop that you want and drag it to your Backpack.

To use an item in your Backpack in another project, open the project and drag the item from the
Backpack to the correct pane or tab.

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 29/31
27/05/2022, 12:01 Grow a dragonfly

To delete an item in your Backpack, find the item in the Backpack tab, then right-click (or on a
tablet, tap and hold) on the item and select delete.

You can hide your Backpack when you are not using it. To do this, click on the Backpack tab at
the bottom of the screen.

Tip: Check that all your sprites and costumes have sensible names. It makes your project easier to
understand if you come back to it later.
Tip: Make sure your code is laid out neatly in the Code area. Right-click on the Code area and choose
Clean up Blocks to get Scratch to tidy up your code.

Completed project
You can view the completed project here (https://scratch.mit.edu/projects/521688740/).

Save your project

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 30/31
27/05/2022, 12:01 Grow a dragonfly

What next?
If you are following the More scratch (https://projects.raspberrypi.org/en/raspberrypi/more-scratch)
pathway, you can move on to the Drum star (https://projects.raspberrypi.org/en/projects/drum-star) project.
In this project, you will make a clicker game where you earn beats to play new drums at bigger venues.

If you want to have more fun exploring Scratch, then you could try out any of these projects (https://projects.ra
spberrypi.org/en/projects?software%5B%5D=scratch&curriculum%5B%5D=%201).

Published by Raspberry Pi Foundation (https://www.raspberrypi.org) under a Creative Commons


license (https://creativecommons.org/licenses/by-sa/4.0/).
View project & license on GitHub (https://github.com/RaspberryPiLearning/grow-a-dragonfly)

https://projects.raspberrypi.org/en/projects/grow-a-dragonfly/print 31/31

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy