Advancers – Week 10

Programming and Spirals

This week we combined 2 Scratch Projects:

  1. The Programming project that we did last week
  2. The Spirals project that we did a while ago

Introduction

We did a lot of jumping around, from one project to the other, as we had to make changes to both projects to get everything working. Once everything was working though, there is a process to follow to get the Programming project to draw the same Spiral as the Spirals project.

Process

  1. Open the Spirals project
  2. Run the Spirals Project so it populates the Commands to run
  3. Right Click the List and Export the list of Commands to a file.
  4. Open the Programming project
  5. Right Click the List and Import the list of Commands from the file created in step 3
  6. Run the Porgramming project and it will draw the same Spiral as the Spirals project.

And this is how we did it….

The Programming Project:

This project turns Scratch in to a Programming language which can draw different things. You “Program” it using the List where you can either write command manually or, as we did, get another Scratch project to write the commands.

Our Programming languge has some rules that we need to follow:

  1. Each “Command” would be 1 Upper Case letter
  2. The Command would be followed by a colon (:)
  3. Following the colon would be any Value that the Command might need

For example, the get the Sprite to Move 10 steps you would put this in the list:

M:10

We put code in place so it would understand all the following Commands:

Scratch CommandOur CommandValue
MOVEM:The number of steps to Move
TURNT:The number of degrees to Turn
Go To XX:The X position the Sprite should move to
Go To YY:The Y position the Sprite should move to
Pen DownP:Down
Pen UpP:Up
Erase AllE:Erase, although this is not strictly necessary
Change Pen colourC:The vlaue the colour should be changed by

So, for example, if you wanted the Sprite to draw a square, you could put the following commands in to the list:

X:0
Y:0
P:Up
E:Erase
P:Down
M:100
T:90
M:100
T:90
M:100
T:90
M:100
T:90

P:Up

The Sprite would draw a square with each side being 100 steps.

You can see though, that writing all the commands in to the list by hand could take quite a while, so wouldn’t it be a good idea if we could get another Scratch Project to write the Commands for us? So that is exactly what we did.

The Spirals Project

We took the Spirals project that we wrote a while ago and made a few simple changes:

  1. We added a List variable
  2. When we told the Sprite to Go To X,Y we added an X:… and Y:… command to the list
  3. When we put the Pen Down we added a P:Down command to the List
  4. When we Moved the Sprite we added a M:… command to the List
  5. When we Turned the Sprite we added a T:… command to the List

We then ran the Spirals project which generated a long list of cammnds to be run, this could be several thousand, depending on how many sides the Spiral had for example.

This is what the code looked like after our changes:

Once the list had been generated, you can then “right” click on the list and Export it to a file.

Once you have the file, you will need to re-open the Programming project, “right” click on the list and Import the file.

Resources

I have loaded both of the projects that we used to Scratch.mit.edu

If you don’t have your own User Id and Password, you can access the projects using:

User : athenryadvancers
Pass : Advancers

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s