Mec e learning2
Transcript of Mec e learning2
Media Computing
Click the arrow to continue
X
ContentsREQUIREMENTSThis e-learning package requires you to
1 Go through this presentation
2 Try the sample scripts provided
3 Create a game using this presentation and the sample scripts to help you
4 Submit your game through LMS
RESOURCESYou should have downloaded the attached files You should have 2 partially completed games
- Alien- Prevent_dengue
X
Navigating
Back to the home page
Quits this presentation
Next page
Click to see more of each script block
Use these button for quick access to each set of scripts
Previous page
X
Select a set of scripts to begin
See Sample scripts Go to Task
X
MotionClick on the scripts on the left to see what each script does to the worm below
X
Move 10 stepsClick on the scripts on the left to see what each script does to the worm below
Moves the sprite 10 steps in the current direction
X
Turn clockwise
Turns the sprite (X) degrees clockwise
Click on the scripts on the left to see what each script does to the worm below
X
Turn Anti-clockwise
Turns the sprite (x) degrees anti clockwise
Click on the scripts on the left to see what each script does to the worm below
X
Point in direction ndash 0o
Points the sprit in a specified direction
180o
90o-90o
0o
Mouse over the different degrees to see what happens
X
Points the sprit in a specified direction
Mouse over the different degrees to see what happens
Point in direction 180o
180o
90o-90o
0o
X
Point in direction -90o
Points the sprit in a specified direction
Mouse over the different degrees to see what happens
180o
90o-90o
0o
X
Point in direction 90o
Mouse over the different degrees to see what happens
Points the sprit in a specified direction
180o
90o-90o
0o
X
Point towardsMouse over the different degrees to see what happens
Points the sprit in a specified direction
X
Go to X YInstantly moves a sprite to a specified coordinate position
Go to X 150 Y -150
X 180
X -180
Y 200Y -200
X 150
Y -150
Centre of the stage is always (0 0)
X
Go to (XX)Instantly moves the sprite the location of another sprite or mouse pointer
Go to ltMouse pointergt Sprite goes to wherever the mouse pointer goes
X
Glide ( )secs to X YGradually moves the sprite to a specified position over a number of seconds
Glide (3) secs to to X 100 Y -50
Y 180
Y -180
X 200X -200
Y -50
X 100
X
Change x by ( )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( )Moves the sprite up or down regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
Change y by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
LooksClick on the scripts on the left to see what each script does to the worm below
X
Switch costume
Allows you to choose which costume to switch to
Automatically switches to the next costume
Switch to costume ( )
Next costume
back
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
ContentsREQUIREMENTSThis e-learning package requires you to
1 Go through this presentation
2 Try the sample scripts provided
3 Create a game using this presentation and the sample scripts to help you
4 Submit your game through LMS
RESOURCESYou should have downloaded the attached files You should have 2 partially completed games
- Alien- Prevent_dengue
X
Navigating
Back to the home page
Quits this presentation
Next page
Click to see more of each script block
Use these button for quick access to each set of scripts
Previous page
X
Select a set of scripts to begin
See Sample scripts Go to Task
X
MotionClick on the scripts on the left to see what each script does to the worm below
X
Move 10 stepsClick on the scripts on the left to see what each script does to the worm below
Moves the sprite 10 steps in the current direction
X
Turn clockwise
Turns the sprite (X) degrees clockwise
Click on the scripts on the left to see what each script does to the worm below
X
Turn Anti-clockwise
Turns the sprite (x) degrees anti clockwise
Click on the scripts on the left to see what each script does to the worm below
X
Point in direction ndash 0o
Points the sprit in a specified direction
180o
90o-90o
0o
Mouse over the different degrees to see what happens
X
Points the sprit in a specified direction
Mouse over the different degrees to see what happens
Point in direction 180o
180o
90o-90o
0o
X
Point in direction -90o
Points the sprit in a specified direction
Mouse over the different degrees to see what happens
180o
90o-90o
0o
X
Point in direction 90o
Mouse over the different degrees to see what happens
Points the sprit in a specified direction
180o
90o-90o
0o
X
Point towardsMouse over the different degrees to see what happens
Points the sprit in a specified direction
X
Go to X YInstantly moves a sprite to a specified coordinate position
Go to X 150 Y -150
X 180
X -180
Y 200Y -200
X 150
Y -150
Centre of the stage is always (0 0)
X
Go to (XX)Instantly moves the sprite the location of another sprite or mouse pointer
Go to ltMouse pointergt Sprite goes to wherever the mouse pointer goes
X
Glide ( )secs to X YGradually moves the sprite to a specified position over a number of seconds
Glide (3) secs to to X 100 Y -50
Y 180
Y -180
X 200X -200
Y -50
X 100
X
Change x by ( )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( )Moves the sprite up or down regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
Change y by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
LooksClick on the scripts on the left to see what each script does to the worm below
X
Switch costume
Allows you to choose which costume to switch to
Automatically switches to the next costume
Switch to costume ( )
Next costume
back
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Navigating
Back to the home page
Quits this presentation
Next page
Click to see more of each script block
Use these button for quick access to each set of scripts
Previous page
X
Select a set of scripts to begin
See Sample scripts Go to Task
X
MotionClick on the scripts on the left to see what each script does to the worm below
X
Move 10 stepsClick on the scripts on the left to see what each script does to the worm below
Moves the sprite 10 steps in the current direction
X
Turn clockwise
Turns the sprite (X) degrees clockwise
Click on the scripts on the left to see what each script does to the worm below
X
Turn Anti-clockwise
Turns the sprite (x) degrees anti clockwise
Click on the scripts on the left to see what each script does to the worm below
X
Point in direction ndash 0o
Points the sprit in a specified direction
180o
90o-90o
0o
Mouse over the different degrees to see what happens
X
Points the sprit in a specified direction
Mouse over the different degrees to see what happens
Point in direction 180o
180o
90o-90o
0o
X
Point in direction -90o
Points the sprit in a specified direction
Mouse over the different degrees to see what happens
180o
90o-90o
0o
X
Point in direction 90o
Mouse over the different degrees to see what happens
Points the sprit in a specified direction
180o
90o-90o
0o
X
Point towardsMouse over the different degrees to see what happens
Points the sprit in a specified direction
X
Go to X YInstantly moves a sprite to a specified coordinate position
Go to X 150 Y -150
X 180
X -180
Y 200Y -200
X 150
Y -150
Centre of the stage is always (0 0)
X
Go to (XX)Instantly moves the sprite the location of another sprite or mouse pointer
Go to ltMouse pointergt Sprite goes to wherever the mouse pointer goes
X
Glide ( )secs to X YGradually moves the sprite to a specified position over a number of seconds
Glide (3) secs to to X 100 Y -50
Y 180
Y -180
X 200X -200
Y -50
X 100
X
Change x by ( )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( )Moves the sprite up or down regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
Change y by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
LooksClick on the scripts on the left to see what each script does to the worm below
X
Switch costume
Allows you to choose which costume to switch to
Automatically switches to the next costume
Switch to costume ( )
Next costume
back
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Select a set of scripts to begin
See Sample scripts Go to Task
X
MotionClick on the scripts on the left to see what each script does to the worm below
X
Move 10 stepsClick on the scripts on the left to see what each script does to the worm below
Moves the sprite 10 steps in the current direction
X
Turn clockwise
Turns the sprite (X) degrees clockwise
Click on the scripts on the left to see what each script does to the worm below
X
Turn Anti-clockwise
Turns the sprite (x) degrees anti clockwise
Click on the scripts on the left to see what each script does to the worm below
X
Point in direction ndash 0o
Points the sprit in a specified direction
180o
90o-90o
0o
Mouse over the different degrees to see what happens
X
Points the sprit in a specified direction
Mouse over the different degrees to see what happens
Point in direction 180o
180o
90o-90o
0o
X
Point in direction -90o
Points the sprit in a specified direction
Mouse over the different degrees to see what happens
180o
90o-90o
0o
X
Point in direction 90o
Mouse over the different degrees to see what happens
Points the sprit in a specified direction
180o
90o-90o
0o
X
Point towardsMouse over the different degrees to see what happens
Points the sprit in a specified direction
X
Go to X YInstantly moves a sprite to a specified coordinate position
Go to X 150 Y -150
X 180
X -180
Y 200Y -200
X 150
Y -150
Centre of the stage is always (0 0)
X
Go to (XX)Instantly moves the sprite the location of another sprite or mouse pointer
Go to ltMouse pointergt Sprite goes to wherever the mouse pointer goes
X
Glide ( )secs to X YGradually moves the sprite to a specified position over a number of seconds
Glide (3) secs to to X 100 Y -50
Y 180
Y -180
X 200X -200
Y -50
X 100
X
Change x by ( )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( )Moves the sprite up or down regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
Change y by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
LooksClick on the scripts on the left to see what each script does to the worm below
X
Switch costume
Allows you to choose which costume to switch to
Automatically switches to the next costume
Switch to costume ( )
Next costume
back
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
MotionClick on the scripts on the left to see what each script does to the worm below
X
Move 10 stepsClick on the scripts on the left to see what each script does to the worm below
Moves the sprite 10 steps in the current direction
X
Turn clockwise
Turns the sprite (X) degrees clockwise
Click on the scripts on the left to see what each script does to the worm below
X
Turn Anti-clockwise
Turns the sprite (x) degrees anti clockwise
Click on the scripts on the left to see what each script does to the worm below
X
Point in direction ndash 0o
Points the sprit in a specified direction
180o
90o-90o
0o
Mouse over the different degrees to see what happens
X
Points the sprit in a specified direction
Mouse over the different degrees to see what happens
Point in direction 180o
180o
90o-90o
0o
X
Point in direction -90o
Points the sprit in a specified direction
Mouse over the different degrees to see what happens
180o
90o-90o
0o
X
Point in direction 90o
Mouse over the different degrees to see what happens
Points the sprit in a specified direction
180o
90o-90o
0o
X
Point towardsMouse over the different degrees to see what happens
Points the sprit in a specified direction
X
Go to X YInstantly moves a sprite to a specified coordinate position
Go to X 150 Y -150
X 180
X -180
Y 200Y -200
X 150
Y -150
Centre of the stage is always (0 0)
X
Go to (XX)Instantly moves the sprite the location of another sprite or mouse pointer
Go to ltMouse pointergt Sprite goes to wherever the mouse pointer goes
X
Glide ( )secs to X YGradually moves the sprite to a specified position over a number of seconds
Glide (3) secs to to X 100 Y -50
Y 180
Y -180
X 200X -200
Y -50
X 100
X
Change x by ( )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( )Moves the sprite up or down regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
Change y by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
LooksClick on the scripts on the left to see what each script does to the worm below
X
Switch costume
Allows you to choose which costume to switch to
Automatically switches to the next costume
Switch to costume ( )
Next costume
back
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Move 10 stepsClick on the scripts on the left to see what each script does to the worm below
Moves the sprite 10 steps in the current direction
X
Turn clockwise
Turns the sprite (X) degrees clockwise
Click on the scripts on the left to see what each script does to the worm below
X
Turn Anti-clockwise
Turns the sprite (x) degrees anti clockwise
Click on the scripts on the left to see what each script does to the worm below
X
Point in direction ndash 0o
Points the sprit in a specified direction
180o
90o-90o
0o
Mouse over the different degrees to see what happens
X
Points the sprit in a specified direction
Mouse over the different degrees to see what happens
Point in direction 180o
180o
90o-90o
0o
X
Point in direction -90o
Points the sprit in a specified direction
Mouse over the different degrees to see what happens
180o
90o-90o
0o
X
Point in direction 90o
Mouse over the different degrees to see what happens
Points the sprit in a specified direction
180o
90o-90o
0o
X
Point towardsMouse over the different degrees to see what happens
Points the sprit in a specified direction
X
Go to X YInstantly moves a sprite to a specified coordinate position
Go to X 150 Y -150
X 180
X -180
Y 200Y -200
X 150
Y -150
Centre of the stage is always (0 0)
X
Go to (XX)Instantly moves the sprite the location of another sprite or mouse pointer
Go to ltMouse pointergt Sprite goes to wherever the mouse pointer goes
X
Glide ( )secs to X YGradually moves the sprite to a specified position over a number of seconds
Glide (3) secs to to X 100 Y -50
Y 180
Y -180
X 200X -200
Y -50
X 100
X
Change x by ( )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( )Moves the sprite up or down regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
Change y by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
LooksClick on the scripts on the left to see what each script does to the worm below
X
Switch costume
Allows you to choose which costume to switch to
Automatically switches to the next costume
Switch to costume ( )
Next costume
back
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Turn clockwise
Turns the sprite (X) degrees clockwise
Click on the scripts on the left to see what each script does to the worm below
X
Turn Anti-clockwise
Turns the sprite (x) degrees anti clockwise
Click on the scripts on the left to see what each script does to the worm below
X
Point in direction ndash 0o
Points the sprit in a specified direction
180o
90o-90o
0o
Mouse over the different degrees to see what happens
X
Points the sprit in a specified direction
Mouse over the different degrees to see what happens
Point in direction 180o
180o
90o-90o
0o
X
Point in direction -90o
Points the sprit in a specified direction
Mouse over the different degrees to see what happens
180o
90o-90o
0o
X
Point in direction 90o
Mouse over the different degrees to see what happens
Points the sprit in a specified direction
180o
90o-90o
0o
X
Point towardsMouse over the different degrees to see what happens
Points the sprit in a specified direction
X
Go to X YInstantly moves a sprite to a specified coordinate position
Go to X 150 Y -150
X 180
X -180
Y 200Y -200
X 150
Y -150
Centre of the stage is always (0 0)
X
Go to (XX)Instantly moves the sprite the location of another sprite or mouse pointer
Go to ltMouse pointergt Sprite goes to wherever the mouse pointer goes
X
Glide ( )secs to X YGradually moves the sprite to a specified position over a number of seconds
Glide (3) secs to to X 100 Y -50
Y 180
Y -180
X 200X -200
Y -50
X 100
X
Change x by ( )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( )Moves the sprite up or down regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
Change y by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
LooksClick on the scripts on the left to see what each script does to the worm below
X
Switch costume
Allows you to choose which costume to switch to
Automatically switches to the next costume
Switch to costume ( )
Next costume
back
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Turn Anti-clockwise
Turns the sprite (x) degrees anti clockwise
Click on the scripts on the left to see what each script does to the worm below
X
Point in direction ndash 0o
Points the sprit in a specified direction
180o
90o-90o
0o
Mouse over the different degrees to see what happens
X
Points the sprit in a specified direction
Mouse over the different degrees to see what happens
Point in direction 180o
180o
90o-90o
0o
X
Point in direction -90o
Points the sprit in a specified direction
Mouse over the different degrees to see what happens
180o
90o-90o
0o
X
Point in direction 90o
Mouse over the different degrees to see what happens
Points the sprit in a specified direction
180o
90o-90o
0o
X
Point towardsMouse over the different degrees to see what happens
Points the sprit in a specified direction
X
Go to X YInstantly moves a sprite to a specified coordinate position
Go to X 150 Y -150
X 180
X -180
Y 200Y -200
X 150
Y -150
Centre of the stage is always (0 0)
X
Go to (XX)Instantly moves the sprite the location of another sprite or mouse pointer
Go to ltMouse pointergt Sprite goes to wherever the mouse pointer goes
X
Glide ( )secs to X YGradually moves the sprite to a specified position over a number of seconds
Glide (3) secs to to X 100 Y -50
Y 180
Y -180
X 200X -200
Y -50
X 100
X
Change x by ( )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( )Moves the sprite up or down regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
Change y by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
LooksClick on the scripts on the left to see what each script does to the worm below
X
Switch costume
Allows you to choose which costume to switch to
Automatically switches to the next costume
Switch to costume ( )
Next costume
back
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Point in direction ndash 0o
Points the sprit in a specified direction
180o
90o-90o
0o
Mouse over the different degrees to see what happens
X
Points the sprit in a specified direction
Mouse over the different degrees to see what happens
Point in direction 180o
180o
90o-90o
0o
X
Point in direction -90o
Points the sprit in a specified direction
Mouse over the different degrees to see what happens
180o
90o-90o
0o
X
Point in direction 90o
Mouse over the different degrees to see what happens
Points the sprit in a specified direction
180o
90o-90o
0o
X
Point towardsMouse over the different degrees to see what happens
Points the sprit in a specified direction
X
Go to X YInstantly moves a sprite to a specified coordinate position
Go to X 150 Y -150
X 180
X -180
Y 200Y -200
X 150
Y -150
Centre of the stage is always (0 0)
X
Go to (XX)Instantly moves the sprite the location of another sprite or mouse pointer
Go to ltMouse pointergt Sprite goes to wherever the mouse pointer goes
X
Glide ( )secs to X YGradually moves the sprite to a specified position over a number of seconds
Glide (3) secs to to X 100 Y -50
Y 180
Y -180
X 200X -200
Y -50
X 100
X
Change x by ( )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( )Moves the sprite up or down regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
Change y by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
LooksClick on the scripts on the left to see what each script does to the worm below
X
Switch costume
Allows you to choose which costume to switch to
Automatically switches to the next costume
Switch to costume ( )
Next costume
back
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Points the sprit in a specified direction
Mouse over the different degrees to see what happens
Point in direction 180o
180o
90o-90o
0o
X
Point in direction -90o
Points the sprit in a specified direction
Mouse over the different degrees to see what happens
180o
90o-90o
0o
X
Point in direction 90o
Mouse over the different degrees to see what happens
Points the sprit in a specified direction
180o
90o-90o
0o
X
Point towardsMouse over the different degrees to see what happens
Points the sprit in a specified direction
X
Go to X YInstantly moves a sprite to a specified coordinate position
Go to X 150 Y -150
X 180
X -180
Y 200Y -200
X 150
Y -150
Centre of the stage is always (0 0)
X
Go to (XX)Instantly moves the sprite the location of another sprite or mouse pointer
Go to ltMouse pointergt Sprite goes to wherever the mouse pointer goes
X
Glide ( )secs to X YGradually moves the sprite to a specified position over a number of seconds
Glide (3) secs to to X 100 Y -50
Y 180
Y -180
X 200X -200
Y -50
X 100
X
Change x by ( )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( )Moves the sprite up or down regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
Change y by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
LooksClick on the scripts on the left to see what each script does to the worm below
X
Switch costume
Allows you to choose which costume to switch to
Automatically switches to the next costume
Switch to costume ( )
Next costume
back
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Point in direction -90o
Points the sprit in a specified direction
Mouse over the different degrees to see what happens
180o
90o-90o
0o
X
Point in direction 90o
Mouse over the different degrees to see what happens
Points the sprit in a specified direction
180o
90o-90o
0o
X
Point towardsMouse over the different degrees to see what happens
Points the sprit in a specified direction
X
Go to X YInstantly moves a sprite to a specified coordinate position
Go to X 150 Y -150
X 180
X -180
Y 200Y -200
X 150
Y -150
Centre of the stage is always (0 0)
X
Go to (XX)Instantly moves the sprite the location of another sprite or mouse pointer
Go to ltMouse pointergt Sprite goes to wherever the mouse pointer goes
X
Glide ( )secs to X YGradually moves the sprite to a specified position over a number of seconds
Glide (3) secs to to X 100 Y -50
Y 180
Y -180
X 200X -200
Y -50
X 100
X
Change x by ( )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( )Moves the sprite up or down regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
Change y by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
LooksClick on the scripts on the left to see what each script does to the worm below
X
Switch costume
Allows you to choose which costume to switch to
Automatically switches to the next costume
Switch to costume ( )
Next costume
back
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Point in direction 90o
Mouse over the different degrees to see what happens
Points the sprit in a specified direction
180o
90o-90o
0o
X
Point towardsMouse over the different degrees to see what happens
Points the sprit in a specified direction
X
Go to X YInstantly moves a sprite to a specified coordinate position
Go to X 150 Y -150
X 180
X -180
Y 200Y -200
X 150
Y -150
Centre of the stage is always (0 0)
X
Go to (XX)Instantly moves the sprite the location of another sprite or mouse pointer
Go to ltMouse pointergt Sprite goes to wherever the mouse pointer goes
X
Glide ( )secs to X YGradually moves the sprite to a specified position over a number of seconds
Glide (3) secs to to X 100 Y -50
Y 180
Y -180
X 200X -200
Y -50
X 100
X
Change x by ( )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( )Moves the sprite up or down regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
Change y by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
LooksClick on the scripts on the left to see what each script does to the worm below
X
Switch costume
Allows you to choose which costume to switch to
Automatically switches to the next costume
Switch to costume ( )
Next costume
back
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Point towardsMouse over the different degrees to see what happens
Points the sprit in a specified direction
X
Go to X YInstantly moves a sprite to a specified coordinate position
Go to X 150 Y -150
X 180
X -180
Y 200Y -200
X 150
Y -150
Centre of the stage is always (0 0)
X
Go to (XX)Instantly moves the sprite the location of another sprite or mouse pointer
Go to ltMouse pointergt Sprite goes to wherever the mouse pointer goes
X
Glide ( )secs to X YGradually moves the sprite to a specified position over a number of seconds
Glide (3) secs to to X 100 Y -50
Y 180
Y -180
X 200X -200
Y -50
X 100
X
Change x by ( )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( )Moves the sprite up or down regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
Change y by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
LooksClick on the scripts on the left to see what each script does to the worm below
X
Switch costume
Allows you to choose which costume to switch to
Automatically switches to the next costume
Switch to costume ( )
Next costume
back
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Go to X YInstantly moves a sprite to a specified coordinate position
Go to X 150 Y -150
X 180
X -180
Y 200Y -200
X 150
Y -150
Centre of the stage is always (0 0)
X
Go to (XX)Instantly moves the sprite the location of another sprite or mouse pointer
Go to ltMouse pointergt Sprite goes to wherever the mouse pointer goes
X
Glide ( )secs to X YGradually moves the sprite to a specified position over a number of seconds
Glide (3) secs to to X 100 Y -50
Y 180
Y -180
X 200X -200
Y -50
X 100
X
Change x by ( )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( )Moves the sprite up or down regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
Change y by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
LooksClick on the scripts on the left to see what each script does to the worm below
X
Switch costume
Allows you to choose which costume to switch to
Automatically switches to the next costume
Switch to costume ( )
Next costume
back
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Go to (XX)Instantly moves the sprite the location of another sprite or mouse pointer
Go to ltMouse pointergt Sprite goes to wherever the mouse pointer goes
X
Glide ( )secs to X YGradually moves the sprite to a specified position over a number of seconds
Glide (3) secs to to X 100 Y -50
Y 180
Y -180
X 200X -200
Y -50
X 100
X
Change x by ( )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( )Moves the sprite up or down regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
Change y by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
LooksClick on the scripts on the left to see what each script does to the worm below
X
Switch costume
Allows you to choose which costume to switch to
Automatically switches to the next costume
Switch to costume ( )
Next costume
back
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Glide ( )secs to X YGradually moves the sprite to a specified position over a number of seconds
Glide (3) secs to to X 100 Y -50
Y 180
Y -180
X 200X -200
Y -50
X 100
X
Change x by ( )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( )Moves the sprite up or down regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
Change y by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
LooksClick on the scripts on the left to see what each script does to the worm below
X
Switch costume
Allows you to choose which costume to switch to
Automatically switches to the next costume
Switch to costume ( )
Next costume
back
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Change x by ( )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( )Moves the sprite up or down regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
Change y by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
LooksClick on the scripts on the left to see what each script does to the worm below
X
Switch costume
Allows you to choose which costume to switch to
Automatically switches to the next costume
Switch to costume ( )
Next costume
back
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Change x by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Change x by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( )Moves the sprite up or down regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
Change y by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
LooksClick on the scripts on the left to see what each script does to the worm below
X
Switch costume
Allows you to choose which costume to switch to
Automatically switches to the next costume
Switch to costume ( )
Next costume
back
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Change x by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( )Moves the sprite up or down regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
Change y by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
LooksClick on the scripts on the left to see what each script does to the worm below
X
Switch costume
Allows you to choose which costume to switch to
Automatically switches to the next costume
Switch to costume ( )
Next costume
back
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons belowt o compare the effect of the 3 different scripts
Change x by (20) Change x by (-20) Move (20) steps
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( )Moves the sprite up or down regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
Change y by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
LooksClick on the scripts on the left to see what each script does to the worm below
X
Switch costume
Allows you to choose which costume to switch to
Automatically switches to the next costume
Switch to costume ( )
Next costume
back
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Move ( 20 ) stepsMoves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( )Moves the sprite up or down regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
Change y by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
LooksClick on the scripts on the left to see what each script does to the worm below
X
Switch costume
Allows you to choose which costume to switch to
Automatically switches to the next costume
Switch to costume ( )
Next costume
back
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Change y by ( )Moves the sprite up or down regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Change y by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
Change y by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
LooksClick on the scripts on the left to see what each script does to the worm below
X
Switch costume
Allows you to choose which costume to switch to
Automatically switches to the next costume
Switch to costume ( )
Next costume
back
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Change y by ( 20 )Moves the sprite left or right regardless of direction the sprite is pointing
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
X
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
Change y by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
LooksClick on the scripts on the left to see what each script does to the worm below
X
Switch costume
Allows you to choose which costume to switch to
Automatically switches to the next costume
Switch to costume ( )
Next costume
back
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Click the buttons below to compare the effect of the 3 different scripts
Change y by (20) Change y by (-20) Move (20) steps
Change y by ( -20 )Moves the sprite left or right regardless of direction the sprite is pointing
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
LooksClick on the scripts on the left to see what each script does to the worm below
X
Switch costume
Allows you to choose which costume to switch to
Automatically switches to the next costume
Switch to costume ( )
Next costume
back
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
LooksClick on the scripts on the left to see what each script does to the worm below
X
Switch costume
Allows you to choose which costume to switch to
Automatically switches to the next costume
Switch to costume ( )
Next costume
back
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
If on edge bounceUsually used when the sprite is moving When the sprite touches the edge of the screen it will ldquobouncerdquo and move in the opposite direction
Start
Mouse over the button below to see an example
X
LooksClick on the scripts on the left to see what each script does to the worm below
X
Switch costume
Allows you to choose which costume to switch to
Automatically switches to the next costume
Switch to costume ( )
Next costume
back
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
LooksClick on the scripts on the left to see what each script does to the worm below
X
Switch costume
Allows you to choose which costume to switch to
Automatically switches to the next costume
Switch to costume ( )
Next costume
back
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Switch costume
Allows you to choose which costume to switch to
Automatically switches to the next costume
Switch to costume ( )
Next costume
back
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Switch costumeLets say the worm below has 3 costume
Costume 1
Costume 1
Costume 2
Click the commands below to see what happens to the worm
Switch to costume (costume 1)
Switch to costume (costume 2)
Switch to costume (costume 3)
Next costume
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
SayAutomatically creates a speech balloon to say a specified text
Say [ How are you ] for (3) secs
How are You
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
ThinkhellipSimilar to the ldquosayrdquo script but creates a thought balloon instead
Think [ How are you ] for (3) secs
How are you
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Change size by ( )Changes the size by a specified amount each time the script is used
Negative numbers will shrink the sprite
Positive numbers will grow the sprite
Size = 100
Size = 150
Size = 50
Change size by ( 50)
Change size by ( - 50)
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Set size to ( )Changes the size by a specified amount once only
Only positive numbers used
Click here to see difference between Change Size and Set Size
Size = 100
Size = 150
Size = 50
Set size to (150)
Set size to (50)
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Change size vs Set sizeThe difference between change size and set size become obvious when the same script is used multiple times
Size = 100
Change size by (30)
script Used 1st time Used 2nd time Used 3rd time
Size = 130 Size = 160 Size = 190
Size = 100
Set size to (30)
Size = 30 Size = 30 Size ndash 30
back
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Show and HideShow the sprite can be seen (visible)
Hide the sprite cannot be seen (invisible)
Show Hide
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
SoundsThis set of scripts allows you to control sounds in your game or animation
Click on one of the highlighted scripts to check what they do
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Play sound ( )Plays a specified sound
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Importing sound effects
Click on the SOUNDS tab to start importing
sound effects
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Importing sound effects
Click on the IMPORT button to select the
sound effect you need
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Importing sound effects
Select the sound that you need and click OK
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Importing sound effects
Your sound effect is now imported
back
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Play sound ( ) until donePlays a specified sound and waits until the sound clip ends before moving on to the next script
Sound effect must be imported into the sprite library for you to be able to use them
Click Here to find out how to import sounds
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Stop all sounds
Stops all sound effects in the game or animation
Usually used when the game ends or when a condition is met
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Control
Click on a set of control scripts
Terminators
Loops and conditionals
When key pressedWhen I receive
When sprite clickedStop
Stop all
If If Then ElseRepeat loopsForever loops
Broadcast
Examples
Examples
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Controls ndash Terminators
Terminators are used to start or stop a set of scripts
Click on a terminator to learn more about it
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
When (green flag) clicked
The green flag is usually used to start the game or animation
Click on the green flag to start
Click on another terminator to continue
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
When ( ) key pressed
Key press can also be used to start a game or animation
Key press is a common method to control characters or sprites in a game
Click on the spacebar above
Space bar
Click ldquospacebarrdquo to change costume again or click MORE continue more
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Key press as controls
Click on the arrow keys to see what each key press does to the worm above
Click on another terminator to continue
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
When sprite clickedThe sprite ldquowormrdquo changes costume when clicked and changes back after 025 seconds
Try clicking on the worm or click another terminator to continue
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Loops and ConditionalsLOOPS A set of scripts that repeats itself
CONDITIONAL LOOPS
A set of scripts that repeats itself until a condition is fulfilled
CONDITIONALS An event that must happen to start a set of scripts
CONDITIONALS An event that must happen to start a set of scripts
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Forever Loops
Scripts inside the forever loop will be repeated over and over again
Forever Loops can be stopped when the ldquoSTOP ALLrdquo command is used
Example
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Conditional Loops
Repeat ( ) Repeat until lt gt
Select one of the conditional loops below to find out more
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Repeat ( ) Repeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds for 3 times and then changes costume
Click here to start
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Repeat until lt gtRepeats the script inside the loop a fixed number of times
In the script on the right the worm moves 10 steps and waits for 05 seconds until it touches the edge and then changes costume
Click here to start
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
ldquoIfrdquo statements
IF lt gt hellip IF lt gt hellip ELSE hellip
If statements specify an event that must happen before the scripts in the statement is run
Select one of the options below to learn more
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Click here to start
34 45Which number
is larger
OR
SCORE 0
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
50 32Which number
is larger
OR
SCORE 1
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
Next question
Correct
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
0 -1Which number
is larger
OR
SCORE 2
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
End game
Correct
SCORE 3
YOU WIN
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
IF lt gt hellipThe event specified in lt gt must happen for the script to run
The script on the right shows part of a game
Click on the larger number to score a point
IF you score 3 points you win
ltlt Back
Wrong answer Please try again
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
IF lt gthellip ELSE hellipThe event specified in lt gt must happen for the script to run
IF lt gt hellip ELSE hellip is used when there are only 2 options Eg YES or NO TRUE or FALSE A or B
Compare the 2 scripts below
Click each one to see how they work
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below
Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Almost there
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Are you sure
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Answer the question below Click the correct answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
You Win
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
IF lt gthellip ELSE hellip
How many hours are there in a day
(A) 24 hours
(B) 30 hours
(C) 78 hours
Answer A
Answer B
Answer C
Wrong Answer
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Notice this speech balloon appeared too early
Restart Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
So much better
Lets change this to BROADCAST AND WAIT
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Start Animation
Back to controls
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
BROADCAST and RECEIVEBROADCAST = Send a message
RECEIVE = receive the message
Sprite 1 Sprite 2
Change your Colour So much better
Back to controls
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Broadcast vs Broadcast and Wait
bull Broadcast ndash Sends the message and continues with the next
script
bull Broadcast and waitndash Sends the message waits for the message to be
received carried out then continues with the next script
Back to controls
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
SensingBlocks found under the sensing section are never used alone except for Ask and Wait
Sensing scripts are used together with other scripts usually conditional loops and ldquoIFrdquo statements
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
OperatorsOperators may be used to specify conditions
They may be used together with sensing blocks control blocks
Click on one of the block on the left to continue
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Mathematical operatorsThese are used when mathematical calculation is needed
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Random Number GeneratorOne of the most commonly used script blocks in game design Generates a random number when used
Click next to see examples
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Examples
Points the sprite in a random direction between 0 to 360
Sets the variable (Scene) to either 1 or 2 randomly
Moves the sprite to a random X-position between -200 and 200
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Logical operators
Greater thanEquals toLess than
Examples of Use
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your score is 5
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Join [ ] [ ]
Example Click the 2 scripts below to see what is said
Joins 2 words togetherUsed together with the ldquosayrdquo script
Your answer A is correct
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
VariablesA variable is a memory location set aside to store
data types such as numbers text or dates This
location will contain something when it is first
used Hence it is important to clear the location
and fill it with the value that you want The
process of filling with a start value is called
initialisation
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
VariablesA common variable that we will use frequently is the score of a game The score is a variable because it keeps changing (varying) when the game is being played We use the ldquosetrdquo instruction to initialise a variable
For example we can set a variable ldquolivesrdquo to a start value of 5 by using this instruction
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Variables
Checking the variable makes that variable visible on screen
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Variables
This instruction can be used to change the value of a variable
The instruction below will change the variable ldquolivesrdquo by 1
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Sample Scripts
Create the scripts for each of the sprite below
Alien Invasion
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Alien invasionOpen the file ldquoAlienrdquo Create the scripts for each of the sprite below
Click the sprites to see the scripts
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Hammer ScriptsMouse over the scripts to see explanations
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Hammer ScriptsMouse over the scripts to see explanations
When the green flag is clicked the hammer is reset to the position X 0 Y 122
Hammer is visible (show)
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Hammer ScriptsMouse over the scripts to see explanations
When spacebar is pressed the hammer moves as if it is being swung
A broadcast message (hit) is sent to see if the hammer hits the alien spaceship
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Hammer ScriptsMouse over the scripts to see explanations
When the right arrow key is pressed the hammer moves right by 10 steps
If the x-position of the hammer is more than 200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Hammer ScriptsMouse over the scripts to see explanations
When the Left arrow key is pressed the hammer moves left by 10 steps
If the x-position of the hammer is less than -200 it is automatically changed to 200
This prevents the hammer from going off the screen
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Initialisation
The Alien spaceship is shown
Lives is reset to 3Score is reset to 0
Spaceship is moved to a random x-position at y128
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
Until score=5 or lives=0 the spaceship is moved downwards every 02 sec
If the spaceship touches green color (the ground) deduct 1 from the variable lives
Resets by appearing in another random location
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
If score = 5 the broadcast a WIN message
Otherwise broadcast a loss message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the broadcast message ldquohitrdquo is received check to see if spaceship is touching the hammer
If touching hammer (sprite 2) increase the score by 1 hide the spaceship
Spaceship reappears at another random x position at the top of the screen
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Background ScriptsMouse over the scripts to see explanations
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When Green flag is clicked the game background is shown
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquoloserdquo broadcast message is received change background to shown lose-game message
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Alien Spaceship ScriptsMouse over the scripts to see explanations
When the ldquowinrdquo broadcast message is received change background to shown win-game message
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Task for submissionCreate a game using scratch as in the video below
Submit your game through Ask n Learn
X
Game title Prevent Dengue
STATE the problem bull This game is about killing Aedes mosquitoes to prevent the
spreading of dengue fever bull The aim is to swing the bat to kill the mosquitoes The mosquito
starts randomly from the left side of the screen and moves towards the right
bull If the bat hits the mosquito the score increases by 1 If the mosquito is not hit the number of lives which begins at 3 will decrease by 1
bull The game ends when 5 mosquitoes are killed or the number of lives equals 0
X
Game title Prevent Dengue
X
Game title Prevent DengueTHINK about what is needed 1 Refer to the flowchart to program the game
2 Plan the code for the background such that it switches to different scenes depending on the different situations The three scenes are start of the game end of the game when 5 mosquitoes are killed and end of the game when number of lives is zero
3 Plan the code for the bat such that it can only move up and down within the screen and it will swing back and forth when the space key is pressed (to simulate hitting the mosquito)
4 Plan the code for the mosquito such that it a) appears randomly at the left side of the screen b) moves from left to right and c) tracks the number of mosquitoes and number of lives
X
Game title Prevent DengueENGAGE in coding 1 Open a new file and use all the images provided
2 Create the code for the background and the bat as planned
3 Save the file as mosquito_ltyour namegt
4 Create the code for the mosquito as planned
5 Save your work
X
Game title Prevent Dengue
SUBMIT your code through LMS Name your file as ldquodengue_your_namerdquo
REFINE your code (Challenge)- You may choose not to attempt this section- Add one or two more mosquitos to your
game
X
The End
- Media Computing
- Contents
- Navigating
- Select a set of scripts to begin
- Motion
- Move 10 steps
- Turn clockwise
- Turn Anti-clockwise
- Point in direction ndash 0o
- Slide 10
- Point in direction -90o
- Point in direction 90o
- Point towards
- Go to X Y
- Go to (XX)
- Glide ( )secs to X Y
- Change x by ( )
- Change x by ( 20 )
- Change x by ( -20 )
- Move ( 20 ) steps
- Move ( 20 ) steps (2)
- Change y by ( )
- Change y by ( 20 )
- Change y by ( -20 )
- If on edge bounce
- If on edge bounce (2)
- Looks
- Switch costume
- Switch costume (2)
- Switch costume (3)
- Switch costume (4)
- Switch costume (5)
- Say
- Thinkhellip
- Change size by ( )
- Set size to ( )
- Change size vs Set size
- Show and Hide
- Show and Hide (2)
- Show and Hide (3)
- Sounds
- Play sound ( )
- Importing sound effects
- Importing sound effects (2)
- Importing sound effects (3)
- Importing sound effects (4)
- Play sound ( ) until done
- Stop all sounds
- Control
- Controls ndash Terminators
- When (green flag) clicked
- When (green flag) clicked (2)
- When ( ) key pressed
- When ( ) key pressed (2)
- Key press as controls
- When sprite clicked
- Loops and Conditionals
- Forever Loops
- Conditional Loops
- Repeat ( )
- Repeat until lt gt
- ldquoIfrdquo statements
- IF lt gt hellip
- IF lt gt hellip (2)
- IF lt gt hellip (3)
- IF lt gt hellip (4)
- IF lt gt hellip (5)
- IF lt gt hellip (6)
- IF lt gt hellip (7)
- IF lt gt hellip (8)
- IF lt gt hellip (9)
- IF lt gthellip ELSE hellip
- IF lt gthellip ELSE hellip (2)
- IF lt gthellip ELSE hellip (3)
- IF lt gthellip ELSE hellip (4)
- IF lt gthellip ELSE hellip (5)
- IF lt gthellip ELSE hellip (6)
- IF lt gthellip ELSE hellip (7)
- IF lt gthellip ELSE hellip (8)
- IF lt gthellip ELSE hellip (9)
- BROADCAST and RECEIVE
- BROADCAST and RECEIVE (2)
- BROADCAST and RECEIVE (3)
- BROADCAST and RECEIVE (4)
- BROADCAST and RECEIVE (5)
- BROADCAST and RECEIVE (6)
- Broadcast vs Broadcast and Wait
- Sensing
- Operators
- Mathematical operators
- Random Number Generator
- Examples
- Logical operators
- Join [ ] [ ]
- Join [ ] [ ] (2)
- Join [ ] [ ] (3)
- Variables
- Variables (2)
- Variables (3)
- Variables (4)
- Sample Scripts
- Alien invasion
- Hammer Scripts
- Hammer Scripts (2)
- Hammer Scripts (3)
- Hammer Scripts (4)
- Hammer Scripts (5)
- Alien Spaceship Scripts
- Alien Spaceship Scripts (2)
- Alien Spaceship Scripts (3)
- Alien Spaceship Scripts (4)
- Alien Spaceship Scripts (5)
- Background Scripts
- Alien Spaceship Scripts (6)
- Alien Spaceship Scripts (7)
- Alien Spaceship Scripts (8)
- Task for submission
- Game title Prevent Dengue
- Game title Prevent Dengue (2)
- Game title Prevent Dengue (3)
- Game title Prevent Dengue (4)
- Game title Prevent Dengue (5)
- The End
-
X
Game title Prevent Dengue
X
Game title Prevent DengueTHINK about what is needed 1 Refer to the flowchart to program the game
2 Plan the code for the background such that it switches to different scenes depending on the different situations The three scenes are start of the game end of the game when 5 mosquitoes are killed and end of the game when number of lives is zero
3 Plan the code for the bat such that it can only move up and down within the screen and it will swing back and forth when the space key is pressed (to simulate hitting the mosquito)
4 Plan the code for the mosquito such that it a) appears randomly at the left side of the screen b) moves from left to right and c) tracks the number of mosquitoes and number of lives
X
Game title Prevent DengueENGAGE in coding 1 Open a new file and use all the images provided
2 Create the code for the background and the bat as planned
3 Save the file as mosquito_ltyour namegt
4 Create the code for the mosquito as planned
5 Save your work
X
Game title Prevent Dengue
SUBMIT your code through LMS Name your file as ldquodengue_your_namerdquo
REFINE your code (Challenge)- You may choose not to attempt this section- Add one or two more mosquitos to your
game
X
The End
- Media Computing
- Contents
- Navigating
- Select a set of scripts to begin
- Motion
- Move 10 steps
- Turn clockwise
- Turn Anti-clockwise
- Point in direction ndash 0o
- Slide 10
- Point in direction -90o
- Point in direction 90o
- Point towards
- Go to X Y
- Go to (XX)
- Glide ( )secs to X Y
- Change x by ( )
- Change x by ( 20 )
- Change x by ( -20 )
- Move ( 20 ) steps
- Move ( 20 ) steps (2)
- Change y by ( )
- Change y by ( 20 )
- Change y by ( -20 )
- If on edge bounce
- If on edge bounce (2)
- Looks
- Switch costume
- Switch costume (2)
- Switch costume (3)
- Switch costume (4)
- Switch costume (5)
- Say
- Thinkhellip
- Change size by ( )
- Set size to ( )
- Change size vs Set size
- Show and Hide
- Show and Hide (2)
- Show and Hide (3)
- Sounds
- Play sound ( )
- Importing sound effects
- Importing sound effects (2)
- Importing sound effects (3)
- Importing sound effects (4)
- Play sound ( ) until done
- Stop all sounds
- Control
- Controls ndash Terminators
- When (green flag) clicked
- When (green flag) clicked (2)
- When ( ) key pressed
- When ( ) key pressed (2)
- Key press as controls
- When sprite clicked
- Loops and Conditionals
- Forever Loops
- Conditional Loops
- Repeat ( )
- Repeat until lt gt
- ldquoIfrdquo statements
- IF lt gt hellip
- IF lt gt hellip (2)
- IF lt gt hellip (3)
- IF lt gt hellip (4)
- IF lt gt hellip (5)
- IF lt gt hellip (6)
- IF lt gt hellip (7)
- IF lt gt hellip (8)
- IF lt gt hellip (9)
- IF lt gthellip ELSE hellip
- IF lt gthellip ELSE hellip (2)
- IF lt gthellip ELSE hellip (3)
- IF lt gthellip ELSE hellip (4)
- IF lt gthellip ELSE hellip (5)
- IF lt gthellip ELSE hellip (6)
- IF lt gthellip ELSE hellip (7)
- IF lt gthellip ELSE hellip (8)
- IF lt gthellip ELSE hellip (9)
- BROADCAST and RECEIVE
- BROADCAST and RECEIVE (2)
- BROADCAST and RECEIVE (3)
- BROADCAST and RECEIVE (4)
- BROADCAST and RECEIVE (5)
- BROADCAST and RECEIVE (6)
- Broadcast vs Broadcast and Wait
- Sensing
- Operators
- Mathematical operators
- Random Number Generator
- Examples
- Logical operators
- Join [ ] [ ]
- Join [ ] [ ] (2)
- Join [ ] [ ] (3)
- Variables
- Variables (2)
- Variables (3)
- Variables (4)
- Sample Scripts
- Alien invasion
- Hammer Scripts
- Hammer Scripts (2)
- Hammer Scripts (3)
- Hammer Scripts (4)
- Hammer Scripts (5)
- Alien Spaceship Scripts
- Alien Spaceship Scripts (2)
- Alien Spaceship Scripts (3)
- Alien Spaceship Scripts (4)
- Alien Spaceship Scripts (5)
- Background Scripts
- Alien Spaceship Scripts (6)
- Alien Spaceship Scripts (7)
- Alien Spaceship Scripts (8)
- Task for submission
- Game title Prevent Dengue
- Game title Prevent Dengue (2)
- Game title Prevent Dengue (3)
- Game title Prevent Dengue (4)
- Game title Prevent Dengue (5)
- The End
-
X
Game title Prevent DengueTHINK about what is needed 1 Refer to the flowchart to program the game
2 Plan the code for the background such that it switches to different scenes depending on the different situations The three scenes are start of the game end of the game when 5 mosquitoes are killed and end of the game when number of lives is zero
3 Plan the code for the bat such that it can only move up and down within the screen and it will swing back and forth when the space key is pressed (to simulate hitting the mosquito)
4 Plan the code for the mosquito such that it a) appears randomly at the left side of the screen b) moves from left to right and c) tracks the number of mosquitoes and number of lives
X
Game title Prevent DengueENGAGE in coding 1 Open a new file and use all the images provided
2 Create the code for the background and the bat as planned
3 Save the file as mosquito_ltyour namegt
4 Create the code for the mosquito as planned
5 Save your work
X
Game title Prevent Dengue
SUBMIT your code through LMS Name your file as ldquodengue_your_namerdquo
REFINE your code (Challenge)- You may choose not to attempt this section- Add one or two more mosquitos to your
game
X
The End
- Media Computing
- Contents
- Navigating
- Select a set of scripts to begin
- Motion
- Move 10 steps
- Turn clockwise
- Turn Anti-clockwise
- Point in direction ndash 0o
- Slide 10
- Point in direction -90o
- Point in direction 90o
- Point towards
- Go to X Y
- Go to (XX)
- Glide ( )secs to X Y
- Change x by ( )
- Change x by ( 20 )
- Change x by ( -20 )
- Move ( 20 ) steps
- Move ( 20 ) steps (2)
- Change y by ( )
- Change y by ( 20 )
- Change y by ( -20 )
- If on edge bounce
- If on edge bounce (2)
- Looks
- Switch costume
- Switch costume (2)
- Switch costume (3)
- Switch costume (4)
- Switch costume (5)
- Say
- Thinkhellip
- Change size by ( )
- Set size to ( )
- Change size vs Set size
- Show and Hide
- Show and Hide (2)
- Show and Hide (3)
- Sounds
- Play sound ( )
- Importing sound effects
- Importing sound effects (2)
- Importing sound effects (3)
- Importing sound effects (4)
- Play sound ( ) until done
- Stop all sounds
- Control
- Controls ndash Terminators
- When (green flag) clicked
- When (green flag) clicked (2)
- When ( ) key pressed
- When ( ) key pressed (2)
- Key press as controls
- When sprite clicked
- Loops and Conditionals
- Forever Loops
- Conditional Loops
- Repeat ( )
- Repeat until lt gt
- ldquoIfrdquo statements
- IF lt gt hellip
- IF lt gt hellip (2)
- IF lt gt hellip (3)
- IF lt gt hellip (4)
- IF lt gt hellip (5)
- IF lt gt hellip (6)
- IF lt gt hellip (7)
- IF lt gt hellip (8)
- IF lt gt hellip (9)
- IF lt gthellip ELSE hellip
- IF lt gthellip ELSE hellip (2)
- IF lt gthellip ELSE hellip (3)
- IF lt gthellip ELSE hellip (4)
- IF lt gthellip ELSE hellip (5)
- IF lt gthellip ELSE hellip (6)
- IF lt gthellip ELSE hellip (7)
- IF lt gthellip ELSE hellip (8)
- IF lt gthellip ELSE hellip (9)
- BROADCAST and RECEIVE
- BROADCAST and RECEIVE (2)
- BROADCAST and RECEIVE (3)
- BROADCAST and RECEIVE (4)
- BROADCAST and RECEIVE (5)
- BROADCAST and RECEIVE (6)
- Broadcast vs Broadcast and Wait
- Sensing
- Operators
- Mathematical operators
- Random Number Generator
- Examples
- Logical operators
- Join [ ] [ ]
- Join [ ] [ ] (2)
- Join [ ] [ ] (3)
- Variables
- Variables (2)
- Variables (3)
- Variables (4)
- Sample Scripts
- Alien invasion
- Hammer Scripts
- Hammer Scripts (2)
- Hammer Scripts (3)
- Hammer Scripts (4)
- Hammer Scripts (5)
- Alien Spaceship Scripts
- Alien Spaceship Scripts (2)
- Alien Spaceship Scripts (3)
- Alien Spaceship Scripts (4)
- Alien Spaceship Scripts (5)
- Background Scripts
- Alien Spaceship Scripts (6)
- Alien Spaceship Scripts (7)
- Alien Spaceship Scripts (8)
- Task for submission
- Game title Prevent Dengue
- Game title Prevent Dengue (2)
- Game title Prevent Dengue (3)
- Game title Prevent Dengue (4)
- Game title Prevent Dengue (5)
- The End
-
X
Game title Prevent DengueENGAGE in coding 1 Open a new file and use all the images provided
2 Create the code for the background and the bat as planned
3 Save the file as mosquito_ltyour namegt
4 Create the code for the mosquito as planned
5 Save your work
X
Game title Prevent Dengue
SUBMIT your code through LMS Name your file as ldquodengue_your_namerdquo
REFINE your code (Challenge)- You may choose not to attempt this section- Add one or two more mosquitos to your
game
X
The End
- Media Computing
- Contents
- Navigating
- Select a set of scripts to begin
- Motion
- Move 10 steps
- Turn clockwise
- Turn Anti-clockwise
- Point in direction ndash 0o
- Slide 10
- Point in direction -90o
- Point in direction 90o
- Point towards
- Go to X Y
- Go to (XX)
- Glide ( )secs to X Y
- Change x by ( )
- Change x by ( 20 )
- Change x by ( -20 )
- Move ( 20 ) steps
- Move ( 20 ) steps (2)
- Change y by ( )
- Change y by ( 20 )
- Change y by ( -20 )
- If on edge bounce
- If on edge bounce (2)
- Looks
- Switch costume
- Switch costume (2)
- Switch costume (3)
- Switch costume (4)
- Switch costume (5)
- Say
- Thinkhellip
- Change size by ( )
- Set size to ( )
- Change size vs Set size
- Show and Hide
- Show and Hide (2)
- Show and Hide (3)
- Sounds
- Play sound ( )
- Importing sound effects
- Importing sound effects (2)
- Importing sound effects (3)
- Importing sound effects (4)
- Play sound ( ) until done
- Stop all sounds
- Control
- Controls ndash Terminators
- When (green flag) clicked
- When (green flag) clicked (2)
- When ( ) key pressed
- When ( ) key pressed (2)
- Key press as controls
- When sprite clicked
- Loops and Conditionals
- Forever Loops
- Conditional Loops
- Repeat ( )
- Repeat until lt gt
- ldquoIfrdquo statements
- IF lt gt hellip
- IF lt gt hellip (2)
- IF lt gt hellip (3)
- IF lt gt hellip (4)
- IF lt gt hellip (5)
- IF lt gt hellip (6)
- IF lt gt hellip (7)
- IF lt gt hellip (8)
- IF lt gt hellip (9)
- IF lt gthellip ELSE hellip
- IF lt gthellip ELSE hellip (2)
- IF lt gthellip ELSE hellip (3)
- IF lt gthellip ELSE hellip (4)
- IF lt gthellip ELSE hellip (5)
- IF lt gthellip ELSE hellip (6)
- IF lt gthellip ELSE hellip (7)
- IF lt gthellip ELSE hellip (8)
- IF lt gthellip ELSE hellip (9)
- BROADCAST and RECEIVE
- BROADCAST and RECEIVE (2)
- BROADCAST and RECEIVE (3)
- BROADCAST and RECEIVE (4)
- BROADCAST and RECEIVE (5)
- BROADCAST and RECEIVE (6)
- Broadcast vs Broadcast and Wait
- Sensing
- Operators
- Mathematical operators
- Random Number Generator
- Examples
- Logical operators
- Join [ ] [ ]
- Join [ ] [ ] (2)
- Join [ ] [ ] (3)
- Variables
- Variables (2)
- Variables (3)
- Variables (4)
- Sample Scripts
- Alien invasion
- Hammer Scripts
- Hammer Scripts (2)
- Hammer Scripts (3)
- Hammer Scripts (4)
- Hammer Scripts (5)
- Alien Spaceship Scripts
- Alien Spaceship Scripts (2)
- Alien Spaceship Scripts (3)
- Alien Spaceship Scripts (4)
- Alien Spaceship Scripts (5)
- Background Scripts
- Alien Spaceship Scripts (6)
- Alien Spaceship Scripts (7)
- Alien Spaceship Scripts (8)
- Task for submission
- Game title Prevent Dengue
- Game title Prevent Dengue (2)
- Game title Prevent Dengue (3)
- Game title Prevent Dengue (4)
- Game title Prevent Dengue (5)
- The End
-
X
Game title Prevent Dengue
SUBMIT your code through LMS Name your file as ldquodengue_your_namerdquo
REFINE your code (Challenge)- You may choose not to attempt this section- Add one or two more mosquitos to your
game
X
The End
- Media Computing
- Contents
- Navigating
- Select a set of scripts to begin
- Motion
- Move 10 steps
- Turn clockwise
- Turn Anti-clockwise
- Point in direction ndash 0o
- Slide 10
- Point in direction -90o
- Point in direction 90o
- Point towards
- Go to X Y
- Go to (XX)
- Glide ( )secs to X Y
- Change x by ( )
- Change x by ( 20 )
- Change x by ( -20 )
- Move ( 20 ) steps
- Move ( 20 ) steps (2)
- Change y by ( )
- Change y by ( 20 )
- Change y by ( -20 )
- If on edge bounce
- If on edge bounce (2)
- Looks
- Switch costume
- Switch costume (2)
- Switch costume (3)
- Switch costume (4)
- Switch costume (5)
- Say
- Thinkhellip
- Change size by ( )
- Set size to ( )
- Change size vs Set size
- Show and Hide
- Show and Hide (2)
- Show and Hide (3)
- Sounds
- Play sound ( )
- Importing sound effects
- Importing sound effects (2)
- Importing sound effects (3)
- Importing sound effects (4)
- Play sound ( ) until done
- Stop all sounds
- Control
- Controls ndash Terminators
- When (green flag) clicked
- When (green flag) clicked (2)
- When ( ) key pressed
- When ( ) key pressed (2)
- Key press as controls
- When sprite clicked
- Loops and Conditionals
- Forever Loops
- Conditional Loops
- Repeat ( )
- Repeat until lt gt
- ldquoIfrdquo statements
- IF lt gt hellip
- IF lt gt hellip (2)
- IF lt gt hellip (3)
- IF lt gt hellip (4)
- IF lt gt hellip (5)
- IF lt gt hellip (6)
- IF lt gt hellip (7)
- IF lt gt hellip (8)
- IF lt gt hellip (9)
- IF lt gthellip ELSE hellip
- IF lt gthellip ELSE hellip (2)
- IF lt gthellip ELSE hellip (3)
- IF lt gthellip ELSE hellip (4)
- IF lt gthellip ELSE hellip (5)
- IF lt gthellip ELSE hellip (6)
- IF lt gthellip ELSE hellip (7)
- IF lt gthellip ELSE hellip (8)
- IF lt gthellip ELSE hellip (9)
- BROADCAST and RECEIVE
- BROADCAST and RECEIVE (2)
- BROADCAST and RECEIVE (3)
- BROADCAST and RECEIVE (4)
- BROADCAST and RECEIVE (5)
- BROADCAST and RECEIVE (6)
- Broadcast vs Broadcast and Wait
- Sensing
- Operators
- Mathematical operators
- Random Number Generator
- Examples
- Logical operators
- Join [ ] [ ]
- Join [ ] [ ] (2)
- Join [ ] [ ] (3)
- Variables
- Variables (2)
- Variables (3)
- Variables (4)
- Sample Scripts
- Alien invasion
- Hammer Scripts
- Hammer Scripts (2)
- Hammer Scripts (3)
- Hammer Scripts (4)
- Hammer Scripts (5)
- Alien Spaceship Scripts
- Alien Spaceship Scripts (2)
- Alien Spaceship Scripts (3)
- Alien Spaceship Scripts (4)
- Alien Spaceship Scripts (5)
- Background Scripts
- Alien Spaceship Scripts (6)
- Alien Spaceship Scripts (7)
- Alien Spaceship Scripts (8)
- Task for submission
- Game title Prevent Dengue
- Game title Prevent Dengue (2)
- Game title Prevent Dengue (3)
- Game title Prevent Dengue (4)
- Game title Prevent Dengue (5)
- The End
-
X
The End
- Media Computing
- Contents
- Navigating
- Select a set of scripts to begin
- Motion
- Move 10 steps
- Turn clockwise
- Turn Anti-clockwise
- Point in direction ndash 0o
- Slide 10
- Point in direction -90o
- Point in direction 90o
- Point towards
- Go to X Y
- Go to (XX)
- Glide ( )secs to X Y
- Change x by ( )
- Change x by ( 20 )
- Change x by ( -20 )
- Move ( 20 ) steps
- Move ( 20 ) steps (2)
- Change y by ( )
- Change y by ( 20 )
- Change y by ( -20 )
- If on edge bounce
- If on edge bounce (2)
- Looks
- Switch costume
- Switch costume (2)
- Switch costume (3)
- Switch costume (4)
- Switch costume (5)
- Say
- Thinkhellip
- Change size by ( )
- Set size to ( )
- Change size vs Set size
- Show and Hide
- Show and Hide (2)
- Show and Hide (3)
- Sounds
- Play sound ( )
- Importing sound effects
- Importing sound effects (2)
- Importing sound effects (3)
- Importing sound effects (4)
- Play sound ( ) until done
- Stop all sounds
- Control
- Controls ndash Terminators
- When (green flag) clicked
- When (green flag) clicked (2)
- When ( ) key pressed
- When ( ) key pressed (2)
- Key press as controls
- When sprite clicked
- Loops and Conditionals
- Forever Loops
- Conditional Loops
- Repeat ( )
- Repeat until lt gt
- ldquoIfrdquo statements
- IF lt gt hellip
- IF lt gt hellip (2)
- IF lt gt hellip (3)
- IF lt gt hellip (4)
- IF lt gt hellip (5)
- IF lt gt hellip (6)
- IF lt gt hellip (7)
- IF lt gt hellip (8)
- IF lt gt hellip (9)
- IF lt gthellip ELSE hellip
- IF lt gthellip ELSE hellip (2)
- IF lt gthellip ELSE hellip (3)
- IF lt gthellip ELSE hellip (4)
- IF lt gthellip ELSE hellip (5)
- IF lt gthellip ELSE hellip (6)
- IF lt gthellip ELSE hellip (7)
- IF lt gthellip ELSE hellip (8)
- IF lt gthellip ELSE hellip (9)
- BROADCAST and RECEIVE
- BROADCAST and RECEIVE (2)
- BROADCAST and RECEIVE (3)
- BROADCAST and RECEIVE (4)
- BROADCAST and RECEIVE (5)
- BROADCAST and RECEIVE (6)
- Broadcast vs Broadcast and Wait
- Sensing
- Operators
- Mathematical operators
- Random Number Generator
- Examples
- Logical operators
- Join [ ] [ ]
- Join [ ] [ ] (2)
- Join [ ] [ ] (3)
- Variables
- Variables (2)
- Variables (3)
- Variables (4)
- Sample Scripts
- Alien invasion
- Hammer Scripts
- Hammer Scripts (2)
- Hammer Scripts (3)
- Hammer Scripts (4)
- Hammer Scripts (5)
- Alien Spaceship Scripts
- Alien Spaceship Scripts (2)
- Alien Spaceship Scripts (3)
- Alien Spaceship Scripts (4)
- Alien Spaceship Scripts (5)
- Background Scripts
- Alien Spaceship Scripts (6)
- Alien Spaceship Scripts (7)
- Alien Spaceship Scripts (8)
- Task for submission
- Game title Prevent Dengue
- Game title Prevent Dengue (2)
- Game title Prevent Dengue (3)
- Game title Prevent Dengue (4)
- Game title Prevent Dengue (5)
- The End
-