Loading...
Hi, everyone.
My name is Mrs. Jenkins.
I can't wait to learn with you today.
Welcome to today's lesson, which is called, "Design to Code.
" It's taken from the unit, "Using variables in programming to develop a game.
" By the end of today's lesson, you'll be able to follow a design to create a programme that uses variables.
In today's lesson, we have two keywords, design and test.
It's really useful to know what these words mean before we get started, as they'll appear throughout the lesson.
So design is a plan that shows how a programme should work, and test is to run a programme to check if it works the way that you planned.
Keep an eye out for those words throughout the lesson.
They are design and test.
In today's lesson, design to code, we have two learning cycles.
We have "Create a programme that uses variables," and "Test and debug a programme.
" Going to start with create a programme that uses variables.
What is a variable?
Laura explains, "A variable is a named piece of data which can be accessed and changed by a programme.
" And Andeep adds to that to explain, "Variables are named and stored in a computer's memory.
" Thank you both of you.
That's really helpful.
Izzy also says, "A variable can be set and changed throughout the running of a programme.
" That's right, Izzy.
Thank you.
On the next slide, watch the animation of the Scratch chatbot programme.
What variables are being set and changed during the running of this programme?
You can use a mini whiteboard or scrap paper to record your ideas.
Have a watch.
Okay, so you're thinking about what variables do you think are being set and changed during the running of the programme.
This is the Scratch bot programme, so we can look at what variables are being set and changed during the running of this programme.
We have, when this sprite clicked.
Ask "What's your name" and wait.
Set name to answer.
Say join, Hi, name, for two seconds.
Ask "How old are you" and wait.
Set age to answer.
Ask, join, are you, age, years old, and wait.
If answer equals yes, then say, "Oh good, I've used variables well" for five seconds.
"A variable called 'name' is set to the answer of 'What's your name?
'" That's right, Sofia.
Thank you.
There we can see we have set name to answer.
So that is the variable name.
"A variable called 'age' has been set to the answer from 'How old are you?
'" That's right.
Thank you, Sofia.
There is also a variable used to check the answers.
Even though it is a blue sensing block, answer is a variable.
Its value can be changed.
There we go.
There is our answer variable there.
Okay, let's have a little check in now.
Which one is not a variable?
Answer, say variable, or variable?
Have a go.
How did you get on?
I asked you which one is not a variable?
Answer, say variable, or variable?
The answer is B, say variable.
Answer A is an answer variable.
It is in the sensing category, but it is still a variable.
Say variable is a say block.
It is in the looks category.
And then variable block, which is in the variables category.
Great job, everyone.
In this lesson, you will use a design to create a catching game.
If you do not have a design, you can use the one that comes with this lesson.
It's available on the additional materials.
You're going to open the Scratch website and create a new project.
This will be the start of your catching game.
Create a sprite, which is a long coloured line.
Make sure this is placed at the bottom of your screen.
Your catching game should have, a variable for the score, at least three falling objects, the object should fall at different speeds, a background to match the theme of your design.
This is the code for the falling star sprite.
So we have, when the green flag has clicked, forever, change y by minus eight, if touching the screen bottom, then go to X, and then it's gotta pick random, minus 240 to 240 y 180.
If touching bowl, then go to X, pick random minus 240 to 240 y 180.
Change the score by three.
The "change y" block is how you set the speed.
A lower number means the sprite falls more slowly.
A higher number means the sprite will fall more quickly.
In Scratch, movements up are done with positive numbers, and down are with negative numbers.
You might have to test the values inside the change y block in order to make sure your sprites fall at different speeds.
Let's have a little check now.
Why does this value use a negative number?
A, the sprite is moving down.
B, the sprite is getting smaller.
Or C, the sprite is changing colour.
What do you think?
Have a go.
How did you get on?
I asked you why does this value use a negative number.
A, the sprite is moving down.
B, the sprite is getting smaller.
Or C, the sprite is changing colour.
The answer is A, the sprite is moving down.
Great job, everyone.
If the star touches the sprite at the bottom of the screen, it will restart at the top of the screen.
The "pick random" operator sets the X coordinate randomly.
This means the sprite starts in different horizontal positions.
So we've got go to X, pick random, minus 240 to 240.
The y is 180.
If the sprite touches the bowl, it will then restart at a random horizontal location at the top of the screen.
The score will increase by three.
To create a variable, open the variables menu and click the "Make a Variable" button.
Add the name of your variable.
Make sure it is appropriate for the values that the variable will be storing.
Once you've added the variable name, click OK.
Your new variable will be seen in the menu here.
If you have more than one variable added, you can choose which one you need in the blocks by choosing the triangle and selecting from the dropdown menu.
Okay, we're going to move on to Task A now.
I would like you to use your design to create your catching game programme.
Your game should have a score, at least three falling objects, the objects should fall at different speeds, and a background matching the theme of your design.
Have a go.
How did you get on?
I asked you for Task A, to use your design to create your catching game programme.
Your game should have a score, at least three falling objects, the object should fall at different speeds, and a background matching the theme of your design.
So my example of my game is here for the oaklink/catch-1.
Great job, everyone.
We're going to move on to learning cycle two now, test and debug a programme.
Izzy and Andeep are working on their programmes.
Izzy says, "My programme has lots of different sequences.
" Andeep said, "Are you testing your programme as you go?
" Testing means running your programme to see if it does what you expected.
You should test your programme to make sure each sprite moves according to your design.
Do they go back to the top once they reach the bottom or the bowl?
Do you remember what finding and fixing mistakes in a programme is called?
"Finding and fixing errors in code is debugging.
You should test your programme often to spot bugs.
" Great job, Andeep.
You're right.
It's really important that you test and debug your game throughout the process.
If you do it early, then you spot the mistakes quickly and are able to make them fixed.
Test your game and try catching the objects.
Does the score change?
Have a go, run your programme, and catch the objects.
Izzy says, "I ran my programme and when I caught an object, my score went up.
" Great job, Izzy.
You might want to think about does your score change depending on the object you catch.
Test your programme often as you go.
Don't wait until the end.
You may find you need to make some changes to your design as you code, and that is fine.
Programmers write code in different ways, but your programme should still have the concepts from your design.
Okay, we're going to have a check in now.
I would like you to fill in the blanks.
Blank your programme often as you go.
You may find you need to make some blank to your blank as you code, and that is fine.
Your programme should still have the blank from your design.
So the words you might need are changes, concepts, programme, and test.
Have a go.
How did you get on?
I asked you to fill in the blanks.
Let's look at the answers.
Test your programme often as you go.
You may find you need to make some changes to your programme as you code, and that is fine.
Your programme should still have the concepts from your design.
Great job, everyone.
If the output from your programme doesn't match your design, you should check these things.
Have you set the variable to the right starting value?
Are you changing the variable at the right time?
Where are you using your "change score by"?
Check the variable names.
Are you using the correct variable in your code?
Look at your loop blocks.
Is the variable being updated too often or not at all?
So it's just some things to think about.
Okay, I've got another check now.
If your output doesn't match your design, you should.
A, look at the variable names.
B, check the values in your code blocks.
C, ignore your algorithm.
Or D, delete the sprite.
What do you think?
Have a go.
How did you get on?
I asked, if your output doesn't match your design, you should.
A, look at the variable names.
B, check the values in your code blocks.
C, ignore your algorithm.
Or D, delete the sprite.
The answer is A and B.
If your output doesn't match your design, you should look at your variable names, and check the values in your code blocks.
Great job, everyone.
We're going to move on to Task B now.
You are going to run your programme and look at how each sprite runs.
For each sprite, test and record.
Do they match the design?
Do the scores increase or decrease as expected?
If not, why not?
How could you fix it?
When the sprite works correctly, record it on your sheet.
Have a go.
How did you get on?
I asked you to run your programme and look at how each sprite runs.
For each sprite, test and record.
Do they match the design?
Do the scores increase or decrease as expected?
If not, why not?
How could you fix it?
When the sprite works correctly, record it on your sheet.
So here is my sheet with my answers recorded.
Sprite 1 was my falling star, and now I have checked and it is tested and working, it has a tick.
Sprite 2 was my planets.
Now they're tested and working.
They have a tick.
Sprite 3 was a rocket.
It is tested and working, so it has a tick.
Great job, everyone.
You've worked really hard in today's lesson.
Well done.
We're gonna summarise what we have learned.
A design can be followed to create a catching game using variables in Scratch.
You can use variables to store and change values during a programme.
And the values affect game behaviour such as using a score.
You should test and debug programmes regularly.
By comparing a program's output With the original design, you can identify and correct mistakes.
Well done, everyone.
You have worked extremely hard today.
Great job.
I hope to learn with you again soon.