28 February 2023
Text-based programming to Scratch Coding in Primary
Why not reverse the usual process and move from text-based to block-based programming. Each has its advantages as outlined below.
Turtle Academy Playground programming needs attention to detail so it is a good place to go from the start of a lesson. N.B. The attached photos show the suggested code for a repeated pattern based on a square both using Turtle Academy and Scratch.
Go to the Turtle Academy Playground page.
First step in programming - draw a line
forward 100 right 90 This draws a simple line and then the turtle turns 90 degrees
Next Step - draw a simple shape remembering the square brackets.
repeat 4 [forward 100 right 90] This draws a simple square.
Next show how the text can be shortened. The students love the fact that they can abbreviate the text and not have to spell the full word - forward (fd), right (rt), left (lt) , clear screen (cs) etc…. More examples are lower down the playground web page.
So for a square the alternative version would be - repeat 4 [fd 100 rt 90]
It is a simple process to change the shape to another one e.g. pentagon has a repeat of 5 and a right turn of 72 degrees (360 /5= 72). Triangles don’t work using internal angles or 360 degrees but that is a good task for the student who races ahead and needs a challenge.
To create the repeat pattern the turtle must turn slightly e.g 5 or 10 degrees each time before drawing the new shape. Line Colours can be added too (setcolor). See the attached photo of the turtle code for details.
setcolor 5 repeat 36 [repeat 4 [fd 100 rt 90] rt 10]
Turtle Academy is an easy way to create a simple repeating pattern and revise some shape maths at the same time!
Scratch repeating shape - open the Scratch Editor
To do the same activity in Scratch as above, use repeat loops, pen down and move code. The pen code will need to be added as extension code (click on the icon in the bottom left corner of the Scratch screen).
The sprite can be left as the cat or changed to a pencil. It can be hidden later when drawing so it doesn't really matter what the sprite is at this stage.
Look at the attached photo of the Scratch code. Add code and test one sprite, drawing one square in your chosen colour and size (number of steps). N.B. Step size in Scratch is not the same as forward steps in Turtle Academy hence the testing.
Next duplicate the sprite (right-click on the sprite icon below the stage) then change the steps and the line colour. The Go to code fixes the new sprite in the same place in the stage so the pattern works. Of course, students may wish to change this element of the code once they understand how it works.
Hide the sprite by choosing to not show. Look below the stage on the left side for an eye shape with a line through it and click on it to hide a sprite. It makes the pattern's appearance looks more magical!
By doing the text-based programming first, the students are more able to edit the Scratch code to create the different shapes they want to base their patterns on. They better understand the maths in the code and why there needs to be a 5 or 10 degree turn before the shape repeats.
The attached photos show the suggested code for a repeated pattern based on a square both using Turtle Academy and Scratch.
N.B. Be warned your students will often only make the lovely symmetrical repeating pattern a few times before they go off in their own unpredictable ways. Just hold onto the hope they might remember the internal angles of some 2d shapes along the way before the cry " How did you do that?" fills the air.
An Extended Version of this activity will be available at the Clubs Conference to be held 24-25th March 2023 at Churchill College, Cambridge.