Section 2 - The Basics of Block - Based Computer Programming

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 66

Section 2 - The Basics Of Block - Based Computer

Programming
X & Y Grid - 20px
Paint Editor
X & Y Grid - 30px
Terms In Scratch
❖Sprite - Sprites are the images on a
Scratch computer program screen.
Every Scratch program is made up of
sprites and the scripts (instructions)
that control them. Scripts are
programmed to make the sprites do
things.
❖ Bitmap - Bitmap, method by which a display space (such as
a graphics image file) is defined, including the colour of
each of its pixels (or bits). In effect, a bitmap is an array
of binary data representing the values of pixels in an
image or display. A GIF is an example of a graphics image
file that has a bitmap. Examples of bitmap graphic
formats include GIF, JPEG, PNG, TIFF, XBM, BMP, and
PCX as well as bitmap (i.e., screen) fonts. The image
displayed on a computer monitor is also a bitmap, as are
the outputs of printers, scanners, and similar devices.
They are created using paint programs like Adobe
Photoshop.
❖ Vector - Vector drawing is different than drawing
with a regular paint app. Vector images look smooth
no matter how far you zoom in or out. There is no
pixelation. Vectors create a smooth and finished
product at any size. In Scratch, the playable
characters in a game are called sprites. Examples of
vector graphic formats are PICT, EPS, and WMF as
well as PostScript and TrueType fonts. These are
created with GIS and CAD applications as well as
drawing programs like FreeHand.
❖Costume - A costume is one out of many
different frames (pictures) of a sprite.
Paint Editor (Scratch) The Paint Editor
is Scratch's built-in image editor. The
Paint Editor allows Scratchers to
create their own sprites and backdrops
using it or adjust to any existing
sprites and backdrops.
❖Stage - The stage is basically the
background of your project. Like
sprites, the stage can have
different costumes that change as
the story plays out. The stage
window is the main area where the
action of your program takes place
❖Background - A backdrop is an
image that can be shown on the
Stage.

★ Array - An array is a variable that can store multiple values.


★ Binary - Using only 0 and 1 as a system of numbers
Motion Blocks

Motion blocks is one of the ten categories of Scratch blocks. They are color-coded
medium-blue and are used to control a sprite's movement. They are available only for
sprites.
- Move ___ Steps
- Turn ___ Degrees
- Turn ___ Degrees
- Go To (Random (Any) Position / Mouse
Pointer)

- Go To x : ___ , y : ___

- Glide ___ Second(s) To


(Random Position / Mouse Pointer)

- Glide ___ Second(s) To x : ___ , y :


___
- Point In Direction _

- Point Towards (Mouse Pointer / Sprite Name(s) )

- Change x By _

- Set x to _

- Change y By _

- Set y to _
- If On Edge, Bounce

- Set Rotation Style (Left - Right / Don’t


Rotate / All Around)

)-
Variables (Variables in programming terminology are simply a
container that can store some value. We can simply think of
a box which has a number in it. The number inside the box
can be increased or decreased using an increment or
decrement operator as and when the program requires.)
Looks Block

Looks block are color-coded purple and are used to control a


sprite's appearance. The block displays a speech bubble with
the specified text for the sprite that runs it, which appears on
the screen for the specified amount of seconds.
- Say ___ For ___ Second(s)
- Say ___
- Think ___ For ___ Second(s)

- Think ___
- Switch Costume To [costumes name(s) ]

- Next Costume

- Switch Backdrop To [bakdrop name(s) / Next


Backdrop / Previous Backdrop / Random
Backdrop ]
- Next Backdrop
- Change Size By ___

- Set Size To ___ %

- Change [Colour / Fisheye / Whirl / Pixelate /


Mosaic / Brightness / Ghost] Effect By ___
- Set [Colour / Fisheye / Whirl / Pixelate / Mosaic /
Brightness / Ghost] Effect To ___
- Clear Graphic Effects
- Show

- Hide

- Go To [Front / Back] Layer

- Go Forward / Backward _ Layer(s)

)-
Variables (Variables in programming terminology are
simply a container that can store some value. We can
simply think of a box which has a number in it. The
number inside the box can be increased or decreased
using an increment or decrement operator as and when
the program requires.)
Sound Blocks

Sound blocks are color-coded pink and are used to control sound and
MIDI (Musical Instrument Digital Interface) functions. The
block will stop any sounds currently being played on all sprites and the
Stage. Pressing the Stop button will also stop all sounds, but is rarely
used as it also stops all the other scripts running in the project.
- Play Sound [sound name(s)] Until Done
- Start Sound [Sound name(s)]
- Stop All Sounds

- Change [Pitch / Pan Left - Right] Effect By ___


- Set [Pitch / Pan Left - Right] Effect To ___

- Clear Sound Effects

- Change Volume By ___


- Set Volume To ___
- Variable
Sound Editor
Events Blocks

Events blocks are the most important set of blocks you'll


use in Scratch. If you don't have an Events block, your
script can't run. Events blocks tell Scratch when to start
running the program by setting a triggering moment,
such as clicking the green flag.
3
2 3

3 3
3
3

1 3

1 - These Blocks Work For Sprites


2 - These Blocks Work For Backdrops
3 - These Blocks Work For Backdrops
- When Green Flag Clicked

- When [Keys Name] Key Pressed

- When This Sprite Clicked


- When Stage Clicked

- When Backdrop Switches To [Backdrop


Name(s)]

- When [Loudness / Timer] > ___


- When I Receive [Message(s) Name]

- Broadcast [Message(s) Name]

- Broadcast [Message (s) Name] and Wait


Control Blocks

Control block is one of the nine categories of scratch


block . They are color coded gold,and are used to control
scripts . In scratch 1.4 and earlier this category also
included the block that are now Event Block.
- Wait ___ Second(s)

- Repeat ___

- Forever
- If ___ Then

- If ___ Then ; Else

- Wait Until ___


- Repeat Until ___

- Stop [ All / This Script / Other Scripts In This Sprite ]

- When I Start As A Clone

- Create Clone Of [ Myself / Sprite(s) Name ]

- Delete This Clone


Clone - A clone is a copy of a sprite, it has the
costumes, scripts and sounds held by the sprite it
was cloned from at the time of cloning. There are a
number of blocks that can be used to clone sprites.
With the create clone of [myself v] block, a sprite
can create a clone of itself or of another sprite in the
project.
- Touching [ Mouse Pointer / Edge / Sprite(s)
Name ]

- Touching Colour ___?

- Colour ___ Is Touching


___?
- Distance To [ Mouse Pointer / Sprite(s)
Name ]
- Ask ___ And Wait

- Variable

- Key [ Keys Name ] Pressed

- Mouse Down

- Mouse X

- Mouse Y
- Set Drag Mode [ Draggable / Not
Draggable ]

)- Variables

- Reset Timer

- [ Background # / Background Name / Volume / Variable(s) Name ] Of


[ Stage / Sprites Name ]
- Current [ Year / Month / Date / Day Of Week / Hour / Minute / Second]
- Days Since 2000

- Variable
Operator Blocks

The Operators blocks are used to compare variables and


values, do calculations with numbers, and work with
strings (text). The hexagonal 'Boolean' blocks are used as
conditions, and return true or false. These blocks can be
used in Control blocks with a hexagonal input.
These Blocks Work Both For Backdrops & Sprites
- ___ + ___

- ___ - ___

- ___ * ___

- ___ / ___

- Pick Random ___ to ___

- ___ > ___


- ___ <
___
- ___ = ___
- ___ And ___

- ___ Or ___

- Not ___

- Join ___ ___

- Letter ___ Of ___


- Length Of ___

- ___ Contains ___?

- ___ mod ___

- Round ___

- ___ Of ___
Variable Blocks

This block is used to reports the value of a variable.


- Make A Variable
- [Variable(s)]

- Set [Variable(s)] to ___

- Change [Variable(s)] by ___

- Show Variable [Variable(s)]

- Hide Variable [Variable(s)]


My Blocks

My blocks allow you to create new blocks for a sprite. You give the
block a name and then define what the new block does using other
Scratch blocks. You can use your new block in any script on the sprite
that owns the block.
- Make a Block
Extensions

Scratch extensions make it possible for Scratch to


interface with external hardware and information
outside of the Scratch website through new blocks.
Extensions are written in JavaScript for the ScratchX
project editor. In Scratch, click on the "More Blocks"
category and select the "Add an Extension" button.
Music Block

A different block lets you select instruments like piano or clarinet.


Other blocks let you set the tempo or the duration of a note. One way
to get creative is the play notes block. The first note specifies the
pitch of the block. The larger the number, the higher the note.
- Play Drum ___ For ___ Beats

- Rest For ___ Beats

- Play Note ___ For ___ Beats

- Set Instrument to ___

- Set Tempo To ___

- Change Tempo by ___

- Variable
Pen Block

To use the Pen blocks in Scratch, you need add the Pen extension. Click on
the Add extension button in the bottom left-hand corner. Click on the Pen
extension to add it. The Pen section then appears at the bottom of the
blocks menu.
- Erase all

- Stamp

- Pen Down

- Pen Up

- Set Pen Colour To ___

- Change Pen [Colour / Saturation / Brightness / Transparency] by ___

- Set Pen [Colour / Saturation / Brightness / Transparency] To ___

- Change Pen Size By ___

- Set Pen Size To ___


Video Sensing Blocks

Video sensing is a new extension added to the Scratch 3.0


programming environment. It uses a video camera as a sensor to detect
motion and color.
- When Video Motion > 10

- Video [Motion / Direction] on [Sprite / Stage]

- Turn Video [On / Off]

- Set Video Transparency To ___


Text to Speech Blocks

The Text to Speech Extension is an extension that


allows projects which use it to output
synthesized speech. The service is provided by
Amazon Web Services. It was added in Scratch 3.0.
- Speak ___

- Set Voice To ___

- Set Language To ___


Translate Blocks

The Translate Extension is an extension that allows users


to translate words between languages using
Google Translate.
- Translate ___ To ___

- Variable

You might also like