0% found this document useful (0 votes)
131 views46 pages

Scratch 1 Lesson 8

1. This document provides lessons and review questions for Scratch Beginners. It covers topics like introducing yourself, using custom blocks, random number generation, decisions with if/else blocks, and adding variables to track score in a game. 2. The later lessons demonstrate how to code a shark game where the shark moves to catch fish sprites that move randomly. It shows adding conditions to check if the shark touches a fish or poison fish. 3. Advanced techniques covered include cloning a fish sprite so there are many on the screen at once, and using broadcasts to communicate between sprites instead of direct sensing conflicts. The goal is to code an interactive game where the shark's score increases by eating fish.

Uploaded by

Tony Sy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
131 views46 pages

Scratch 1 Lesson 8

1. This document provides lessons and review questions for Scratch Beginners. It covers topics like introducing yourself, using custom blocks, random number generation, decisions with if/else blocks, and adding variables to track score in a game. 2. The later lessons demonstrate how to code a shark game where the shark moves to catch fish sprites that move randomly. It shows adding conditions to check if the shark touches a fish or poison fish. 3. Advanced techniques covered include cloning a fish sprite so there are many on the screen at once, and using broadcasts to communicate between sprites instead of direct sensing conflicts. The goal is to code an interactive game where the shark's score increases by eating fish.

Uploaded by

Tony Sy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 46

Scratch Beginner

IT’S VERY
EXCITING TO
SCRATCH

Lesson 8

1
Introduce yourselves!
1. Name and Age

2. Where are you from?

3. What’s your favorite hobby?

2
Homework Presentation
• Draw with Gobo

• Was it easy to make gobo draw


• How did you use stamp?

• How did you use the following blocks?

3
Homework Presentation

How can the button change the color of the


other sprites.

Who is the broadcaster ? And who is the


receiver ?

4
Review: More Blocks
• What can we use More Blocks to
do?
• How do we make a custom block
using More Blocks?
1
• What kinds of blocks can we put
inside a custom block? 2
• Can we directly move code from
another part of the program into
a custom block?
4

3
5
Review: More Blocks
• What can we use More
Blocks to do?
• How do we make a new
script block using More 1
Blocks?
• What kinds of blocks can 2
we put inside the new
script block?
• Can we directly move code 3
from another part of the
program into a custom
block? 4
6
Review: Position
X=0
Y=180
Y=0

X=-240 X=240

Y=-180
Review: Position
X=?
Y=180
Y=?

X=-240 X=240

Y=-180
Review: Position
X=?
Y=180
Y=?

X=-240 X=240

Y=-180
Review: Position
X=?
Y=180
Y=?

X=-240 X=240

Y=-180
Review: Position
X=?
Y=180
Y=?

X=-240 X=240

Y=-180
Review: Pick Random
• What can Pick Random do for us?
• How do we use Pick Random?
• Where can we put Pick Random?
• What is the difference between Pick Random and Go To
Random?

• Where could we use Pick Random in Motion?


Where could we use Pick Random in Looks?
Where could we use Pick Random in Sound?
Where could we use Pick Random in Control?
Crazy Aliens!
• Using Pick Random gives
us a lot of freedom to
make our programs fun
and different! Random
allows the result to be
different every time
• Let’s make the alien:
• Change to a random color:
How can we do that?
• Spin a random amount:
How can we do that?
• Move to a random place:
How can we do that?
Crazy Aliens!
• Your Turn! Let’s also:
1. Choose a random tempo (100 to 400)
2. Play a random note:
• How to choose a random instrument? 1 1
to
• How to choose a random note? to
18
3. Play a random drum: 21
• How to choose a random drum?
4. Put everything in a custom block
5. Duplicate
the alien!
• Save your work
48 to 72
Catch me if you can
• The sprite will go to random
x and y
• Then show up
• Wait for random period
• And hide again for random
time

• Can you do it using go to random position script block?

• What’s the difference ?


Revision Questions!
What is the Minimum and
Maximum X position?

What is the Minimum and


Maximum Y position?

How could I repeat something a


random number of times?

If my code is too long, how can I


use more block to make it easier
to understand?

Can I put a custom block inside


another custom block?
16
Making decisions in Scratch
• How do we make decisions in everyday life? Does anyone
know how we make decisions in programming?

Who here likes pizza better? Who here likes noodles better?
I like pizza better! If I had 2 options for lunch, my thinking would be:
“If there is pizza, then I will eat it. Or else , I will eat noodles”
Programming in Scratch is exactly the same!
Everyone tell me how they would choose which lunch to eat
Making decisions in Scratch
• When we are making decisions, the “or else” part is
optional! Sometimes you don’t need it.
• I am not very hungry, but I like pizza:
If there is pizza then I will eat it.
(if there is no pizza, I won’t eat anything)
• I am hungry! I need to eat something! I prefer to eat pizza,
but I will also eat noodles:
If there is pizza, then I will eat it. Or else , I will eat
noodles

• Who can give an example of when we do/don’t need


Break Time

19
Unfriendly Penguin!
• The penguin doesn’t like being touched!
• We use if… then… else… to decide what the
penguin will say:

What is the difference?


Which one should we use?
Unfriendly Penguin!
• What else did you notice about the code we used in this
program? Can anyone tell me? (2 things)
1. How did we tell when the mouse is touching the
penguin?
• Another important part of
Scratch! Touching can be used
in many ways (touching mouse,
touching another sprite,
touching certain color)
2. Why do we use forever here?
• When we need to keep testing something, we have to
Your Turn!
1. Create an underwater scene
2. When the green flag is
clicked, loop forever testing if
the shark is touching the mouse
with if… then… else…
3. If the shark is touching the
mouse, play a chomp sound
until done and say “Got You!”
4. Or else, point towards the
mouse, move 5 steps, and say
“I’m going to eat you!”
5. Save your work
Sharks eat fish, not your mouse!
• Let’s make the shark eat a fish!
• Add a fish sprite and make it
swim in a circle forever
• Who can tell me what kind of
sensing we need to check when
the shark catches the fish?
• How can we use a forever loop
and if… then… to test if the
shark is touching the fish?
• Hide the fish, wait, go to
random location, show the fish
• Save your work
Let’s add score
• What’s data and What’s variable ?
• Variable is an information store
• In motion group … X , Y are a store

1. Could you give me another variable


in scratch.

2. What operation can we apply on a


new variable
Let’s add score
• What’s data and What’s variable ?
• Variable is an information store
• In motion group … X , Y are a store

1. Could you give me another variable


in scratch
Let’s add score
• Make a new variable call it
score.

• Create a new block script


using more blocks to
handle the score issues
• Increase the score when
the shark eat the fish
• If the shark ate many
fishes you can make the
fish say some thing
Sharks eat fish!
Sharks eat fish!
1. Shark moves with your mouse
• Add a shark sprite and make it
start at the origin point (0,0)
• and swim forever and follow
your mouse
Sharks eat fish!
Shark moves with your mouse

• Who can tell me


what is the
difference between
two codes?

• If helps to stop the shark


when it arrive to the
mouse pointer, by checking
the distance between
shark and mouse pointer
Sharks eat fish!
Can we make the shark stop
moving using another way?

Not operator and if… test if the


shark did not sense something
sharks eat fish
2. Yellow fish moves randomly
• Add a yellow fish sprite and
make Enter the stage, and move
randomly.
• Enter the stage from right
(x=240) or left (x= -240) edge.
• To choose between right or left
edge we pick a random number
between 1 to 2.
• If it is 1, the fish enters from left
• Else it enters from right
sharks eat fish
2. Yellow fish moves randomly
• Move randomly in random direction
• Who can tell me how can we make it
moves randomly ?

Use pick random to turn


random direction
sharks eat fish
3. Check if shark ate the fish
• Yellow fish is eaten when it touch shark.
• Don’t make two sprites sense conflict events
• Instead use broadcast
sharks eat fish
3. Check if shark ate the fish
• When yellow fish is eaten, scour will increase by 1
• shark will change color and play chop sound
• And yellow fish will disappear and go to enter the stage again
sharks eat poison fish
To make it more challenging , we add a poison fish
(red fish) kills the shark by reset the score
It moves the same as yellow fish
But what the difference in the code

When shark eats Red fish, a wolfHowl sound


will be played
And change color
The score will goes to zero
Sharks eat fishes!

Let’s add
many
yellow
fishes
Sharks eat fishes!_ (Clone)
Let’s add many yellow fishes
To add many yellow fishes together on the stage we just make
copy of the original one.
Who can tell me how to make a copy of sprite on the stage?

1- duplicate tool

2- stamp script
3- Clone
What is clone?
It’s a temporary duplicate of the specified
sprite without code
Note: The clone only lasts while the project is
running
Choose which sprite to clone from the drop-
down menu.
To tell the clone what to do once it's
created use

Make sure to delete the clone when you


finish,
sharks eat fish
The background will create 10
clones of yellow fish sprite
Timer
What is timer?
• It’s a way to know how long time we have been running the project

• It starts when we open a project.


• It resets automatically when we click the green flag
• We can use to reset the timer during running time

• We can deal with timer as any other variable


Let’s win and finish the game
How to win?
• let’s see how much can you scour in 1 minute

• This code will stop the game after 1 minute, can you
explain it
Timer
• We can move with timer We can move with timer

We can make sprite draw automatically


Practice with Timer
• Try to use your imagination and create some thing interesting
• with Timer
Free Practice

Make anything you want!


Experiment with different Scripts

44
Homework Task 1
• Choose one of the games to make
from your book

• EITHER the maze game on page 59

• OR the pong game on page 60

• After you make your game, answer


the questions on page 64

• Save your work to show the class


next time!

45
Homework Task 2
• Create a new project to animate
Tom and Jerry game

• Tome is going to catch Jerry

• Use the keyboard arrows to move


the cat

• Make the mouse move as you like

• Ad score to count how many


Jerrys your cat can eat

• Save your work to show the class


next time!
46

You might also like