<< Chapter < Page Chapter >> Page >

A moonscape background from the gallery was used for the project shown in Image 4 .

Controlling the behavior of a sprite

You control the behavior of a sprite by writing one or more scripts that belong to the sprite. In reality, each script is an event handler ofsorts. Usually you will have one event handler that executes when the user clicks the green flag at the top right in Image 6 . This is particularly true if any special initialization code is required for the sprite, such assetting the current costume to a particular costume, for example.

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) but doesn't yet have any sprites. The stage is represented by the rectangularthumbnail image in the bottom right 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 left to expose the blocks contained in a particular toolbox in thetoolbox pane. The toolbox pane is the large pane on the left.
  4. Drag blocks from the toolbox to the scripts (center) 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, the language isn't a particularly goodlanguage from a computer science viewpoint. Of the ten or fifteen programming concepts that most computer science professors consider to befundamental to good programming, Scratch supports only a few. Those few include:

Questions & Answers

how does Neisseria cause meningitis
Nyibol Reply
what is microbiologist
Muhammad Reply
what is errata
Muhammad
is the branch of biology that deals with the study of microorganisms.
Ntefuni Reply
What is microbiology
Mercy Reply
studies of microbes
Louisiaste
when we takee the specimen which lumbar,spin,
Ziyad Reply
How bacteria create energy to survive?
Muhamad Reply
Bacteria doesn't produce energy they are dependent upon their substrate in case of lack of nutrients they are able to make spores which helps them to sustain in harsh environments
_Adnan
But not all bacteria make spores, l mean Eukaryotic cells have Mitochondria which acts as powerhouse for them, since bacteria don't have it, what is the substitution for it?
Muhamad
they make spores
Louisiaste
what is sporadic nd endemic, epidemic
Aminu Reply
the significance of food webs for disease transmission
Abreham
food webs brings about an infection as an individual depends on number of diseased foods or carriers dully.
Mark
explain assimilatory nitrate reduction
Esinniobiwa Reply
Assimilatory nitrate reduction is a process that occurs in some microorganisms, such as bacteria and archaea, in which nitrate (NO3-) is reduced to nitrite (NO2-), and then further reduced to ammonia (NH3).
Elkana
This process is called assimilatory nitrate reduction because the nitrogen that is produced is incorporated in the cells of microorganisms where it can be used in the synthesis of amino acids and other nitrogen products
Elkana
Examples of thermophilic organisms
Shu Reply
Give Examples of thermophilic organisms
Shu
advantages of normal Flora to the host
Micheal Reply
Prevent foreign microbes to the host
Abubakar
they provide healthier benefits to their hosts
ayesha
They are friends to host only when Host immune system is strong and become enemies when the host immune system is weakened . very bad relationship!
Mark
what is cell
faisal Reply
cell is the smallest unit of life
Fauziya
cell is the smallest unit of life
Akanni
ok
Innocent
cell is the structural and functional unit of life
Hasan
is the fundamental units of Life
Musa
what are emergency diseases
Micheal Reply
There are nothing like emergency disease but there are some common medical emergency which can occur simultaneously like Bleeding,heart attack,Breathing difficulties,severe pain heart stock.Hope you will get my point .Have a nice day ❣️
_Adnan
define infection ,prevention and control
Innocent
I think infection prevention and control is the avoidance of all things we do that gives out break of infections and promotion of health practices that promote life
Lubega
Heyy Lubega hussein where are u from?
_Adnan
en français
Adama
which site have a normal flora
ESTHER Reply
Many sites of the body have it Skin Nasal cavity Oral cavity Gastro intestinal tract
Safaa
skin
Asiina
skin,Oral,Nasal,GIt
Sadik
How can Commensal can Bacteria change into pathogen?
Sadik
How can Commensal Bacteria change into pathogen?
Sadik
all
Tesfaye
by fussion
Asiina
what are the advantages of normal Flora to the host
Micheal
what are the ways of control and prevention of nosocomial infection in the hospital
Micheal
what is inflammation
Shelly Reply
part of a tissue or an organ being wounded or bruised.
Wilfred
what term is used to name and classify microorganisms?
Micheal Reply
Binomial nomenclature
adeolu
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