<< Chapter < Page Chapter >> Page >

In addition to the green-flag script, you can also write scripts to handle mouse events, key events, and a special type of event that fires when one spritebroadcasts a message to one or more other sprites. Therefore, Scratch projects are not only sprite-based; they are also event-based. These arerelatively advanced concepts in most programming environments. However, Scratch was designed in such a way as to make it easy to write event-handlerscripts to control the behavior of sprites.

Drag and drop programming

Creating Scratch programs involves very little typing. Instead, scripts are created by constructing stacks of blocks, where each block imparts somespecific behavior to a sprite or to the stage. For example, the project being developed in Image 6 has a stage, (which is always the case) and has a single sprite wearing a costume for a cat. The stage is represented by the rectangularthumbnail image in the bottom left area of Image 6 . Any sprites that are added to the project would also appear as thumbnail images in that same area.I will refer to this area as the sprite list area.

The physical process for writing a script is as follows:

  1. Select the stage or a sprite in the sprite list area that is to be programmed.
  2. Select the Scripts tab in the center pane.
  3. Select one of the color-coded buttons in the toolbox button area at the top of the center pane to expose the blocks contained in a particulartoolbox in the toolbox pane. The toolbox pane is the center pane currently showing the blue blocks in Image 6 .
  4. Drag blocks from the toolbox to the scripts (rightmost) pane. (Several blocks have already been dragged to the scripts pane in Image 6 .)
  5. Go back to 3 and continue this process until you have all of the blocks that you need in the scripts pane.
  6. Snap the blocks together in the correct arrangement to create a script that produces the desired behavior.

You will learn the details of such operations in future modules.

Costumes and sounds

Selection of the other two tabs showing at the top of the center pane in Image 6 exposes the controls for importing, editing, and creating costumes and backgrounds, as well as recording and/or importing sound files to be used asmusic and sound effects.

The Scratch programming language

Despite the fact that Scratch has amassed a huge following since its Beta release on March 4, 2007, in my opinion, version 1.4 of the language wasn't a particularly goodprogramming language from a computer science viewpoint. Of the ten or fifteen programming concepts that most computer science professors consider to befundamental to good programming, Scratch v1.4 supported only a few. Those few include:

  • Variables and literals
  • Sequence, selection, and loop structures
  • Arithmetic, relational, and logical operators

These are very important concepts but notably absent was programmer-defined procedures, functions, or methods. I am happy to report that v2.0 seems to haveresolved that deficiency.

Version 2.0 makes it possible for the programmer to create new blocks and to save those new blocks for use in ways that programmers in other languages useprocedures. I will have much more to say about this in a future module.

Questions & Answers

what is biology
Hajah Reply
the study of living organisms and their interactions with one another and their environments
AI-Robot
what is biology
Victoria Reply
HOW CAN MAN ORGAN FUNCTION
Alfred Reply
the diagram of the digestive system
Assiatu Reply
allimentary cannel
Ogenrwot
How does twins formed
William Reply
They formed in two ways first when one sperm and one egg are splited by mitosis or two sperm and two eggs join together
Oluwatobi
what is genetics
Josephine Reply
Genetics is the study of heredity
Misack
how does twins formed?
Misack
What is manual
Hassan Reply
discuss biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles
Joseph Reply
what is biology
Yousuf Reply
the study of living organisms and their interactions with one another and their environment.
Wine
discuss the biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles in an essay form
Joseph Reply
what is the blood cells
Shaker Reply
list any five characteristics of the blood cells
Shaker
lack electricity and its more savely than electronic microscope because its naturally by using of light
Abdullahi Reply
advantage of electronic microscope is easily and clearly while disadvantage is dangerous because its electronic. advantage of light microscope is savely and naturally by sun while disadvantage is not easily,means its not sharp and not clear
Abdullahi
cell theory state that every organisms composed of one or more cell,cell is the basic unit of life
Abdullahi
is like gone fail us
DENG
cells is the basic structure and functions of all living things
Ramadan
What is classification
ISCONT Reply
is organisms that are similar into groups called tara
Yamosa
in what situation (s) would be the use of a scanning electron microscope be ideal and why?
Kenna Reply
A scanning electron microscope (SEM) is ideal for situations requiring high-resolution imaging of surfaces. It is commonly used in materials science, biology, and geology to examine the topography and composition of samples at a nanoscale level. SEM is particularly useful for studying fine details,
Hilary
cell is the building block of life.
Condoleezza Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Teaching beginners to code. OpenStax CNX. May 27, 2013 Download for free at http://cnx.org/content/col11498/1.20
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Teaching beginners to code' conversation and receive update notifications?

Ask