Create a spiral
This challenge has been written by Lydie El-Halougi and is part of the EU CODE WEEK CHALLENGES.
Target Audience
  1. Primary School students (6 to 12 years)
  2. Lower Secondary School students (12 to 16 years)
Experience
  1. Intermediate
Duration
  1. 1 hour
Purpose
  1. To learn and practice loop and variables.
  2. To enhance creativity in coding.
Recommended Materials
  1. Scratch
Description
In this challenge you will write a project with Scratch to create a spiral, using the pen blocks, a loop and a variable.
Instructions
    The Pen blocks
  • Create a new project and name it Spiral.
  • Click on the purple icon “Add extension” on the bottom-left side of the window
  • Select “pen”: the pen blocks are now available for your project!
  • To start your project, drag and drop the “when green flag clicked” block:
  • You need to start with a blank page: within the pen blocks, add the “erase all” block:
  • You want to start drawing at the center of the stage, which means your sprite has to go to the center of the stage (0,0):
  • Your sprite can move without drawing, or move and draw:
  • when you want it to draw, you can use the pen down block
  • when you don’t want that, you can use the pen up block
  • Now, you want to draw! Add the “pen down” block:
  • The hexagon
  • Add the blocks below to your project:
  • You now have one sixth of your hexagon. You need to repeat this sequence 6 times:
  • The spiral
  • To create a spiral, you’ll need to add 2 to the length of each next side.
  • To do so, you will use a variable.
  • In the variable blocks, click on Make a Variable
  • Name it length, then click OK:
  • The spiral is going to grow, you’ll need to start small: set the first length to 10, and insert this block before the loop.
  • Insert the variable “length” in the “move … steps” block
  • To have the spiral grow, you also need to have the length grow in every loop: add the block below at the end of the loop:
  • Here is your current project:
  • A beautiful spiral
  • You drew a spiral! For it to go on and on, replace the “repeat 6” loop with the “forever” loop:
  • To draw a colorful spiral, add the following block in the loop:
  • When you start over, the sprite draws an unwanted line. To prevent it, add a “pen up” block at the beginning of the project.
  • Here’s your final project:
  • Congratulations! You created a lovely spiral!
Share the link to your work in your Instagram Bio: tap the Edit Profile button on your Instagram and add the link to your work in the Website field. After that, create a new post, add a screenshot of your work, write “Link in Bio”, add the hashtag #EUCodeWeekChallenge and mention @CodeWeekEU.
Example
Click here to download this challenge as a word document.