Computer Science Course of Study (WA)

 

Sequence

Page history last edited by Mike Leishman 3 mos ago

Sequence

 

All procedural computer programs consist of a sequence of instructions. In it's simplest form, these instructions consist of a simple list of tasks the computer has to achieve.

 

Drawing Images

Scratch has a Logo like set of instructions that allows a "pen" to be moved over the canvas available. By moving the mouse cursor over the canvas and looking on the right hand side of the canvas, you can easily see that the 0,0 corrdinates are in the centre of the screen, and the grid is 480 x 360 pixels.

 

Task 1 Draw an image of a bird in flight (ref 1)

 

Process

Make a grid where x axis is -240 to +240 and y axis is -180 to +180. Draw the required shape and note the (x,y) coordinates of the line end-points.

 

 

The code for this drawing is below. Note that it is just a sequence of steps.

 

 

Exercises

1 Write programs to draw some other simple line shapes such as a car, robot or boat.

2 Use the alternate programming statements of move and turn to achieve a similar image as above.

 

Task 2 Play a simple tune

Scratch provides a statement that allows users to enter numerical values that represent a musical note and duration of the note. This enables tunes to be played.

 

Mozart's Twinkle Twinkle little star is quite easy to construct. The musical notation for this is here. (ref 2)

 

 

The following image of a musical stave maps the numeric values for the notes on the music.

 

 

This allows the following code to be created (with a little thinking).

 

 

Exercises

1. Complete the rest of Twinkle Twinkle Little Star. As an extra, you could change the instrument being played and then try to syncronise some drums to the tune.

2. Create a tune of your own choice. A quick search of the Internet will provide you with a simple overview of musical notation to help with your translation.

3. (Challenge) You can get Scratch to play your tune while you record your voice singing the words (record using Stereo Mix). Import your saved recording and have scratch play it using the Play Sound statement at the same time as the music plays.

4. Create a simple musical instrument such as a Xylophone that will provide the user with about 2 octave with which to play. You should be able to play simple tunes such as "Twinkle Twinkle Little Star"

 

Reference

1. The BBC Micro Book, McGregor & Watt P5

2. http://en.wikipedia.org/wiki/Twinkle_Twinkle_Little_Star

 

Comments (0)

You don't have permission to comment on this page.