Professional Documents
Culture Documents
E531C Level Up A.01.02 - Watermark PDF
E531C Level Up A.01.02 - Watermark PDF
Scratch is a project of the Lifelong Kindergarten Group at the MIT Media Lab. It is provided free of charge. With Scratch, you can
program your own interactive stories, games, and animations — and share your creations with others in the online community.
Super Mario is a platform video game developed and published by Nintendo as a pseudo-sequel to the 1983 game, Mario Bros.
Arkanoid is an arcade game released by Taito in 1986. Pac-Man is an arcade game developed by Namco, first released in Japan as
Puck Man in May 1980 and was licensed for distribution in the United States by Midway Games and released in October 1980. Angry
Birds is a video game franchise created by Finnish company Rovio Entertainment. Pivot Animator is a stickman animation software
that is provided free for personal and commercial use. Piskel is a free online editor for animated sprites or pixel art.
The information in this manual has been obtained from sources believed to be reliable. The author does not guarantee the accuracy
or completeness of any information presented herein, and shall not be responsible for any errors, omissions or damages as a result of
the use of this information. No part of this manual may be reproduced, copied, or distributed in any form or by any means without
expressed written consent from Chumbaka Sdn Bhd.
3
Read Me First
Before starting the lesson, please have the following items ready.
1. Computer (with heavy use of mouse or touchpad) running Windows or macOS with
Google Chrome browser
4
This page is intentionally left blank.
5
Lesson Scorecard
A1 - Play the Super Mario game.
Software Setup Set up Scratch Desktop. 10
Play Super Mario Get a feel of the Super Mario game. 11
Scanner and Plotter Plot coordinate values on paper with your buddy. 13
B1 - Learn about variables and programming multiple sprites.
Pong Game Create a bouncing ball game. 22
Two-Player Pong Remix the Pong game into a two-player game. 30
C1 - Learn motion sensing and use variables to flag conditions.
Photo Booth Add funny props to a photo. 44
Air Mouse Interact with sprites by waving your hands in front of 55
your computer’s webcam.
D1 - Learn about animation and graphic design.
Create 2D Animation Learn the basic features of Pivot Animator. 64
Animate with Piskel Create more advanced 2D animation. 73
E1 - Learn about projectile motion.
Jump Up in Space Simulate motion when there’s no gravity. 86
Jump Up on Earth Simulate motion when there is gravity. 88
Jump at an Angle Simulate motion when jumping at an angle. 90
F1 - Learn about X-Y coordinates, flowcharts, and Boolean.
Navigation Make a sprite walk and jump. 96
Ground or Air Program the sprite to interact with ground. 100
Animation Animate the sprite to appear to be walking or falling. 104
G1 - Learn about relative movement for animation.
Relative Movement Animate with relative movement. 122
World Construction Create the world for your game. 126
H1 - Learn about hiding sprites, broadcasting, and using text-to-speech.
Music Add background music and sound effects. 146
Collision Detection Detect which part of the sprite collides with other sprites. 149
I Spy Game Play a guessing game with your friends. 156
6
I1 - Learn to create an end-game condition.
Game Start Create the start screen and actions when the game starts. 166
Game Complete Create the actions when the game is completed. 169
Game Over Implement the actions when the game ends. 175
J1 - Learn to create a scoring system using sprites.
Collect Coins Create a scoring system based on the coins collected. 188
Goomba Add Goomba and program its actions. 196
______
Total Score
of 25
7
Challenge Scorecard
Signature
Project Guardian Mentor Guardian Mentor
Green Challenge Red Challenge
8
Final Project Scorecard
Signature
Project
Guardian Mentor
______
Total Score
of 1
To be eligible for a digital badge, you need meet the criteria above. Ask your mentor and guardian
for their signatures as proof of completion. When you’ve completed the programme, take a photo
of these scorecards and upload it to your Chumbaka backpack account.
9
A1 Play the Super Mario game.
Software Setup
Set up Scratch Desktop.
10
Play Super Mario
Get a feel of the Super Mario game.
11
Super Mario Bros is a platform video
game developed and published by
Nintendo as a pseudo-sequel to the
1983 game, Mario Bros.
In 2005, IGN's poll named the "pioneering" and "highly influential" title as
the "greatest game of all time", considering it to have aided in
resurrecting the crashed American video game market of the 1980s. The
game has also sold enormously well, and was the best-selling game of all
time for a single platform for approximately three decades at over 40
million units until Nintendo's Wii Sports took that title.
12
Scanner and Plotter
Plot coordinate values on paper with your buddy.
16
15
14
13
12
11
10
9
8
Draw the X-Y axis and
7 number the grid.
6
5
4
3
2
1
0 X
10
11
12
13
14
15
1
2
3
4
5
6
7
8
9
0
13
2 Transfer a simple image between you and your buddy.
16
15
14
13
X X X X X X
12
X X X X
11 Without showing the plotter,
X X X X
10
X X X
draw a simple shape on your
9
X X
8
X X graph paper. Here’s an example.
7
X X
6 Try other simple shapes that
X X
5
X X
you fancy.
4
X X
3
X
2
1
0 X
10
11
12
13
14
15
1
2
3
4
5
6
7
8
9
0
scanner plotter
If you are a scanner, If you are the plotter, plot the shape
transfer the coordinates on your graph paper.
to the plotter.
When you’re done, show the scanner.
Was the image transferred correctly?
14
3 Swap roles and transfer a more complicated image.
scanner plotter
15
A2 Play Blockly to learn coding concepts.
Recap
Learning from previous chapter.
Y
The horizontal direction is called X.
16
Blockly CHALLENGE
1 Launch Blockly.
17
3 Play Bird and learn about conditionals.
18
5 Play Movie and learn about x-y coordinates.
19
Blockly Advanced CHALLENGE
20
2 Continue with the earlier stages and see how far you can go.
21
B1 Learn about variables and programming multiple sprites.
Pong Game
Create a bouncing ball game.
22
Pick a color.
Select the
Line tool.
We want a
thick line so
In this example, we increase the
choose red. width.
23
2 Add a ball and have it bounce off the edges of the Stage.
24
Move your ball to a starting position.
25
3 Add a paddle and have it follow your mouse pointer.
Try it out!
26
4 Make the ball bounce off the paddle and make a sound.
Try it out!
27
5 Stop the game if the ball touches the red line.
28
6 Create a scoring system.
29
Two-Player Pong
Remix the Pong game into a two-player game.
2 Add another paddle for the second player and modify the controls.
30
Draw an orange paddle.
31
Set the starting position of the
two paddles.
Orange paddle:
Press the Z key to move left.
Press the X key to move right.
Green paddle
Press the left arrow key to move left.
Press the right arrow key to move right.
32
3 Create a scoring system for two players.
Right-click and
duplicate this
script.
33
Try it out! Play
with your buddy
and see who gets
the higher score.
34
This page is intentionally left blank.
35
B2 Create an Arkanoid-based game.
Recap
Learning from previous chapter.
36
2 In Pong, you added ball and paddle objects into the Stage. They are
called sprites.
In two-dimensional (2D)
games, sprites can be a
static image or animated.
37
Arkanoid CHALLENGE
1 Add a brick.
38
Adjust the size to your fancy.
39
2 Change how the ball bounces.
Add these blocks such that the ball bounces off the brick.
40
3 Add more bricks.
41
Add these blocks such that the ball
bounces off either bricks.
42
Arkanoid Enhanced CHALLENGE
2. The game stops when the ball touches the bottom edge or
when all the bricks have been destroyed.
43
C1 Learn motion sensing and use variables to flag conditions.
Photo Booth
Add funny props to a photo.
44
2 Take a photo as the backdrop.
45
3 Add a prop: moustache.
46
Move to the starting
position when the
program starts.
47
4 Add a control: enlarge.
Increase value of
SizeMoustache when
the mouse pointer
touches the control AND
the mouse is clicked.
48
Try and click the sprite and observe
how the value change.
49
5 Add a prop: spectacles.
50
To copy a script from one sprite to another, drag the script and
release it at the destination sprite.
51
Increase the
moustache size if
it is selected.
52
6 Add the remaining control: shrink.
53
7 Add audible feedback for props and controls.
When you’re
done, try it out!
54
Air Mouse
Interact with sprites by waving your hands in front of your computer’s webcam.
Do you see
yourself in the
Stage?
55
2 Try out the webcam.
56
Make the cat meow louder
when you touch it more
vigorously.
Try it out!
57
C2 Create Air Music.
Recap
Learning from previous chapter.
58
Air Music CHALLENGE
Create a virtual touch pad that you play by moving your fingers in the air.
59
Create a new sprite.
Try it out!
60
2 Select different instruments to play.
61
Set the type of instrument
depending on which
×4 instrument is selected.
×4
×4
×4
62
Try it out! Can you play
different notes from different
instruments?
Each person
plays 4 notes.
63
D1 Learn about animation and graphic design.
Create 2D Animation
Learn the basic features of Pivot Animator.
Source: http://bit.ly/2Qaz9nG
64
3 Create your first animation.
65
c
66
c
c
Continue creating more frames.
c
c
c
c
c
c
c
In the last
frame, click
to delete the
stickman.
67
Start the animation.
68
4 Add the animation to Scratch.
Click OK.
69
Start a new Scratch
program.
70
Move the stickman to the
middle of the Stage.
71
Select the stickman.
72
Animate with Piskel
Create more advanced 2D animation.
Piskel.zip
Piskel.dmg
Piskel Applications
73
2 Create an animation.
74
Draw this circle using your mouse.
75
Display the color palette.
76
Duplicate this frame 3
times.
77
3 Add the animation to Scratch.
78
Start a new Scratch
program.
79
Resize the sprite.
80
Upload backdrop from E531C
Mentor Folder/Media/Piskel/
Bomb.jpg.
81
Select this sprite and add these sounds:
×4
82
When your program gets more
complex, you can right-click to
clean up the workspace. The
blocks will be rearranged nicely.
83
D2 Create a story using what you learned.
Recap
Learning from previous chapter.
Source: http://bit.ly/2Qaz9nG
84
Complete Each Other’s Story CHALLENGE
3 Share your completed story with the class in the next lesson.
85
E1 Learn about projectile motion.
Jump Up in Space
Simulate motion when there’s no gravity.
86
When the program starts, move the cat to
its initial position and set its initial
velocity (u).
Try it out!
87
Jump Up on Earth
Simulate motion when there is gravity.
v=u+a*t
88
Try out the program and
see how differently the
cat jumps.
Mars
Jupiter
89
Jump at an Angle
Simulate motion when jumping at an angle.
Breakdown u u(y) u
to horizontal
velocity (u(x))
and vertical
velocity (u(y)).
u(x)
90
Replace with these blocks.
91
E2 Create a projectile-based game.
Recap
Learning from previous chapter.
92
Angry Bird CHALLENGE
93
2 Watch a video (1:06) to see how Angry Bird is played.
Ready… aim…
94
Angry Bird Enhanced CHALLENGE
1 Enhance the game with at least 3 of the features below or any other
cool features you can think of:
95
F1 Learn about X-Y coordinates, flowcharts, and Boolean.
Try it out!
96
2 Move the cat to the left.
97
3 Move the cat up and down.
98
4 Make the cat fall with acceleration.
99
Ground or Air
Program the sprite to interact with ground.
180
y
–240 240
x
–180
100
2 Check if the cat touches the ground.
Otherwise, ground = 0.
101
3 The cat falls only when it is in the air.
102
4 The cat jumps only when it is on the ground.
103
Animation
Animate the sprite to appear to be walking or falling.
104
Delete these costumes.
Start
Change x by –10
Stop
105
Start
Costume=Walk-R1
Wait 0.05s
Right arrow THEN Costume=Walk-R2 To animate Mario, we
key pressed? Wait 0.05s
Costume=Walk-R3
change Mario’s
Wait 0.05s costume quickly when
the right arrow or left
arrow key is pressed.
Costume=Walk-L1
Wait 0.05s
Left arrow THEN Costume=Walk-L2
key pressed? Wait 0.05s
Costume=Walk-L3
Wait 0.05s
×6
106
Start The fix is to add an IF-THEN-ELSE block such that
IF ground=0 (Mario is jumping), show his jump costume
ELSE ground=1 (Mario is on the Floor), show his walk
costume
ground=0 THEN
?
Costume=Walk-R1
Wait 0.05s
THEN THEN
Right arrow Costume=Walk-R2 Right arrow
key pressed? key pressed? Costume=Jump-R
Wait 0.05s
Costume=Walk-R3
Wait 0.05s
Costume=Walk-L1
Wait 0.05s THEN
Left arrow THEN Costume=Walk-L2 Left arrow Costume=Jump-L
key pressed? Wait 0.05s key pressed?
Costume=Walk-L3
Wait 0.05s
×2
107
F2 Create a falling mouse game.
Recap
Learning from previous chapter.
180
y
–240 240
x
–180
108
Watch E531C Mentor Folder/
Videos/Coordinate Plane
Song.mp4 to understand
more about X-Y coordinates.
Source: https://goo.gl/Yxed7K
Source: http://smbc-comics.com/
109
3 Boolean has two possible values: TRUE or FALSE.
false
If d = 700, this Boolean expression is _____________
For this expression to be TRUE, the first and the second Boolean
must be TRUE.
111
Add a sprite you
fancy and delete the
cat.
Start
Right THEN
arrow key Change x by 10
pressed?
Left arrow
×2
THEN
key Change x by –10
pressed?
112
2 Make a mouse fall down the Stage.
Start
Go to the
starting
coordinates
Move Mouse
down the Stage
113
3 After reaching the bottom, make the mouse reappear at a
random position on top of the Stage.
Mouse appears at a
random position and
falls down the Stage.
Start
Go to the
starting
coordinates
Move Mouse
down the Stage
114
4 Play a sound when the trampoline catches the mouse.
Start
Go to the
starting
coordinates
Move Mouse
down the Stage
115
Remember to save your
program.
116
Complete signing up.
117
Start a new project.
118
Falling Mouse Enhanced CHALLENGE
1. Scoring system.
119
2. Gravity effect.
120
4. Fall at different speeds.
121
G1 Learn about relative movement for animation.
Relative Movement
Animate with relative movement.
A B C
We will use a technique called relative movement to give the appearance that an
object is moving inside a world.
In the example above, the dinosaur sprite is actually stationary. Instead, we move the
world around him. This makes the dinosaur appear to be moving.
122
1 Move the Floor in your Mario game.
123
Modify your script
with these blocks.
124
Add these blocks into your script.
125
World Construction
Create the world for your game.
126
y = -160
Floor Floor2
x=0 x = 650
127
2 Add more world sprites.
128
129
×6
Set ground = 1 and velocity = 0
should Mario touch any of the
×6 new sprites you added.
130
3 Add block sprites.
131
Create this script.
132
Make a copy of this sprite to get block2.
133
×2
Add these blocks such that
ground = 1 and velocity = 0
×2
should Mario touch any of the
block sprites you added.
134
Remember to save your
program.
135
G2 Create a flight simulator game.
Recap
Learning from previous chapter.
1 Have you ever been in a car at a junction, and you look out the window
at the car stopped next to you. Suddenly you feel like your car is going
backward, when in fact you’ve not actually moved. Instead it’s the car
next to you that is moving.
This method is used in the Flight Simulator game you will create next,
as well as in some 2D computer games, to simulate movement.
136
2 The offset value is used to determine the initial position of the
background sprites that make up the game world.
x=0 x = 650
offset
137
Flight Simulator CHALLENGE
138
2 Add sprites into the game world and move them instead of the plane.
139
Add a cloud sprite and position to
your fancy.
140
3 Construct the game world.
1. Add more obstacles. You can add more graph paper to create a
larger game world.
2. For each sprite you add to the world, modify the y and offset
values.
4. Try out your program and explore the world you created.
x=200
x=100
x=0
x= –160
y= –130
y=120
y=0
141
4 Control the plane’s height to avoid obstacles.
×2
Try it out! Can you control the plane?
×2
142
The plane tilts upwards and
downwards when it changes
height.
143
Flight Simulator Enhanced CHALLENGE
1 Enhance the game with at least 3 of the features below or any other
cool features you can think of:
1. Scoring system.
2. Special effects.
144
3. Game world continues to scroll.
145
H1 Learn about hiding sprites, broadcasting, and using text-to-speech.
Music
Add background music and sound effects.
146
Make the sound play whenever
Mario jumps.
Try it out!
Try it out!
147
3 Play background music.
Select Stage.
148
Collision Detection
Detect which part of the sprite collides with other sprites.
So far we can detect if Mario touches certain objects, but we can’t tell which part of
the body is involved. For example, if we know the head is hitting a brick wall, we can
have a bounce-back effect to make the motion more realistic.
149
The x position for Topcollide is
the same as Mario, which is
always x = 0.
Broadcast a CollideTop
message if the Topcollide
sprite touches any of these
sprites:
Wall3wide
Wall3wide2
Floor4
×2
×3
150
Create a bounce-back effect.
151
2 Create collision detection for right side.
152
The x position for Sidecollide
is in front of Mario, x = 15.
x = 15
153
3 Create collision detection for left side.
154
4 Make the collision detection bars invisible.
155
I Spy Game
Play a guessing game with your friends.
I Spy is a guessing game. One player becomes the spy and selects an object in the
room in secret. The other players have to guess what the object is.
spy players
2 The spy chooses an object in the class that the players can see. Think
about this object and don’t let the players know.
spy players
156
3 The spy gives a hint to the players by saying, “I spy with my little eye
something that…” and finishes the hint with something that describes
the object.
spy players
157
H2 Create an Eye-Spy game.
Recap
Learning from previous chapter.
Ghosted sprites can say things, and other sprites can detect when they
are touching them.
However, hidden sprites can't say anything, and other sprites can't
detect when they are touching them.
Visit https://goo.gl/3X6W9D to
see a demonstration that
compares a ghosted sprite (red
cat) with a hidden sprite
(orange cat).
158
2 The broadcast block triggers actions in other sprites.
For example, how do you make two sprites say the ABCs in the
correct order?
159
Eye-Spy
CHALLENGE
Create a game where the player finds objects according to the hints.
160
2 Add background music.
161
If the player guesses correctly, a
red circle appears.
162
Duplicate more sprites for other objects
that matches your hint.
163
4 Speak the hints.
164
Eye-Spy Enhanced
CHALLENGE
165
I1 Learn to create an end-game condition.
Game Start
Create the start screen and actions when the game starts.
166
You want your start
screen sprite to cover
the whole Stage.
167
Allow control for
Mario only when
startGame message is
received.
168
Game Complete
Create the actions when the game is completed.
169
Upload sprite from E531C Mentor
Folder/Media/Flag/flag.png.
170
Upload sound from E531C Mentor
Folder/Media/Sound/Stage Clear.wav.
171
2 Touch-up the game.
172
White columns on the
left and right sides of
the Stage.
173
Uncheck all variables so they don’t
appear on Stage.
174
Game Over
Implement the actions when the game ends.
1 Program what happens when Mario touches the bottom of the Stage.
175
When the gameOver message is
received, the following actions
happen:
flag variable endGame
switch Mario’s costume to Die
stop all sounds and play Die
make Mario jump up
stop the program after a
certain delay
176
Initialise variable endGame to
zero when the game starts.
177
3 Disable control keys when the game ends.
178
Ensure Mario animates only
while endGame = 0.
179
I2 Create a Space Invaders-based game.
Recap
Learning from previous chapter.
180
Space Invaders
CHALLENGE
181
2 Rotate a spaceship using the left and right arrow keys.
182
3 Shoot a laser from the spaceship.
183
Try it out.
184
4 End the game when the laser touches the alien.
185
Space Invaders Enhanced
CHALLENGE
186
Make the alien appear at
random lengths of time
before it disappears.
187
J1 Learn to create a scoring system using sprites.
Collect Coins
Create a scoring system based on the coins collected.
188
Upload sound from E531C Mentor
Folder/Media/Sound/Coin1.wav.
×4
189
When Mario touches the coin, the
following happens:
play a sound
coin disappears
broadcast message coin
190
191
4 Create a sprite-based scoring system.
Resize it to a size
you fancy.
192
Make a copy of this costume.
193
Move the sprite to a position
you fancy.
194
Add the character X here.
195
Goomba
Add Goomba and program its actions.
The game ends if Mario collides with Goomba. However Mario can kill Goomba by
stepping on it.
196
Make Goomba continuously
move left.
197
When Mario steps on Goomba,
the following happens:
set variable goombaDie = 1
make Mario jump
198
2 Broadcast gameOver when Mario collides with Goomba.
Try it out!
199
3 Create the game over screen.
200
Hide the game over screen and position
it at (0,0).
201
J2 Create your version of Pac-Man.
Recap
Learning from previous chapter.
202
Pac-Person CHALLENGE
203
2 Add Pac-Person into the game.
204
3 Control Pac-Person with the keyboard.
205
Animate Pac-Person when it
moves to the right.
×3
×3
206
4 Pac-Person is not supposed to pass through the walls.
207
5 Add a dot for Pac-Person to collect.
208
6 Add more dots and sound effects.
209
Pac-Person Continued
CHALLENGE
210
Make the ghost go to its starting
position when you run the
program.
211
These groups of blocks make the
ghost move in four directions: up,
down, left, and right.
212
2 Enhance the game with at least 3 of the features below or any other
cool features you can think of:
3. Add more bonus dots, with each bonus dot scoring points.
213
This page is intentionally left blank.
214
215
RESPECT
I will listen when others are sharing.
I will put up my hand to ask for permission.
I will be punctual.
_______________________
_______________________
RESPONSIBILITY
I will keep my goals.
I will take care of all properties.
I will keep my work space tidy.
_______________________
_______________________
RESOURCEFULNESS
I will check if there are any mistakes in my work.
I will search for answers before asking for help.
I will be creative in solving my problems.
_______________________
_______________________
216