Computer Programming with Scratch

SL-Scratch

Today was the first day of Mr Boo’s new project (for more information about Project Based Homeschooling see this post). He has chosen to create a video game using the program Scratch. He has used it before, but not much, and he wanted my help in creating a proper game. This turned out to be a great project – I didn’t realize what a wide variety of learning would be involved.

He started by importing a generic background image from Minecraft. He chose a crab to be his first character (or “sprite”, as they are called). Eventually he added another sprite, coloured the “ground”, and added an obstacle (the brown block). Here’s a screen shot showing where he left off today:

Screen Shot 2013-09-27 at 5.41.51 PM

But first, he started with just the red crab and the background (the pink bar was originally white). He attempted to program the sprite to move right or left with the right or left arrow keys, respectively. However, he ran into trouble when he could not get the sprite to change direction – it just rotated about its axis instead.

I suggested we watch a tutorial and Mr. Boo searched YouTube. He chose this one by MrMattperrault that shows how to make a sprite jump more realistically by incorporating gravity and velocity changes into the motion of jumping and falling.

At the beginning of the video the narrator reviews how to make the character move left and right. By looking at the scripts Mr. Boo learned where he had gone wrong: to change direction left or right you need to set x to positive or negative numbers (the magnitude of the number is how many steps the character takes when the key is pressed). He also saw that to get a character to jump (and thus fall back down rather than just moving up higher) he needed to set y to positive and negative numbers (with a slight delay in between).

Screen Shot 2013-09-27 at 5.20.03 PM

The main topic of the video was how to get a character to jump realistically – in other words, incorporating acceleration due to gravity. Mr Boo immediately wanted to try this, and so he copied the scripts from the video. Not only did he get a lesson in physics about why things bounce, but he was introduced to the concept of velocity and how that relates to gravity for the sake of programming movement. And, he was also introduced to the concept of conditional phrases: “if/then”. Finally, he learned that multiplying anything by -1 changes it’s sign (and thus, in this case, the direction of motion). Here is a script that causes the character to drop onto the ground:

Screen Shot 2013-09-27 at 5.58.11 PM

Basically this says if the character is touching the colour blue (which was the ground in the video demo) then it needs to stop moving, and if it isn’t touching blue (the ground) it needs to fall. Mr Boo programmed his sprite according to these directions and, at first, the character wouldn’t move. With some assistance from me, we figured out the problem. There was a white rectangle along the bottom of the background, and we’d programmed the sprite to stop falling when it touched white. However, there is also white in the sky so that’s why the character wasn’t moving. When Mr Boo changed the ground to pink it worked.

Before wrapping up for today he added a second character and a block to jump over. He’ll program them next Project Time.

About these ads

One thought on “Computer Programming with Scratch

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s