Presentation is loading. Please wait.

Presentation is loading. Please wait.

Moving Around in Scratch The Basics… -You do want to have Scratch open as you will be creating a program. -Follow the instructions and if you have questions.

Similar presentations


Presentation on theme: "Moving Around in Scratch The Basics… -You do want to have Scratch open as you will be creating a program. -Follow the instructions and if you have questions."— Presentation transcript:

1 Moving Around in Scratch The Basics… -You do want to have Scratch open as you will be creating a program. -Follow the instructions and if you have questions grab me and I will help you out.

2 The Basics File Name Command Groups Commands

3 Getting your Specs (specifications) When you are a programmer you are handed instructions. Those instructions are often called specs, which just means the specifications or specifics of the program that you are going to write. The specs will explain to you what the program will do. Well written specs leave little to the imagination. They should be as specific as possible. If you read the specs and still have questions about how the program is supposed to work you should go to the person that wrote the specs and discuss your questions with them. It is ALWAYS better to eliminate confusion BEFORE you start to code.

4 Poorly Written Specs Let’s use some poorly written specs to learn about the programming process as well as how to move around in Scratch.

5 Your Specs You will write code to make a sprite move around the screen following the pattern of a rectangle.

6 First Things First Change the background to use the xy grid. Click this button to select the correct background

7 First Things First It should look like this before you begin.

8 First Things First Change the file name for this project to ‘Moving Around in Scratch’ Make sure to save your work frequently. Even though this is stored in the ‘cloud’, which is really just another off site server, you still want to save frequently. The cloud just like anything else that involves programming and electricity is NOT PERFECT.

9 Problem #1 The default starting position of Sprite1 is x=0 and y=0. That’s probably not where we should start to move around the screen in a rectangle. If this was a real world situation you would get with the person that wrote the specs and ask them for more specific direction about where the sprite should start. In this case I am the guy who wrote the specs so I will say the sprite should start in the upper left hand corner. It’s still not very specific but it does give you enough to get the ball rolling.

10 First Try The starting point for Sprite1 is x -187 Y 115 Which will look like this.

11 Why Specs Are Important One way to accomplish the task of moving around the screen in the pattern of a rectangle is accomplished with the code on the next slide. Go ahead and put this code in and we will break it down line by line.

12 Is this what we wanted? The trigger is the ‘Space’ key When you run this code what happens? Does anything happen? Well let’s make a few changes and then run the code one more time.

13 A Closer Look When you run this code you see that you are in fact moving around the screen in the pattern of a rectangle but… Do you really think this is what the specs want you to do? Holds here for 1 second before going to the next command.

14 Go To The go to command will ‘jump’ you to a specific x and y location on the screen. The jump is immediate and you will not see the Sprite move. When using a go to the direction that the sprite is pointing DOES NOT MATTER.

15 Second Try The starting point for Sprite1 is x -187 Y 115 Leave all of the code from the first try

16 Is this what we wanted (part 2)? The trigger is the ‘a’ key -When you run this code what happens? -It looks exactly like the last code so lets slow it down a little bit. -Make the modifications on the next slide and then run the code again..

17 A Closer Look -You have now seen two different ways to move around the screen in the pattern of a rectangle but in both cases the Sprite moves so fast that we can’t even see it. -We are forced to use the ‘wait 1 secs’ command to slow the program down. -That might be something that we want but since the specs aren’t specific enough we just don’t have enough information to know for sure. -IMPORTANT – Make sure to run the code a few times so that you can get a sense for how SEQUENCE works. The wait command is slowing the computer down so that you can actually watch it execute the commands you have given it in the SEQUENCE that you gave them.

18 Move Can move in small increments like 10 steps or large increments like 100 steps. Will move in whatever direction the sprite is currently facing. If you want to move backwards you can use a negative number and the sprite will move in reverse.

19 One More Time The starting point for Sprite1 is x -187 Y 115 Leave all of the code from the first & second attempts

20 Is this what we wanted (part 2)? The trigger is the ‘b’ key -When you run this code no wait is required. -When you run this code you can actually see the Sprite moving from position to position. -This seems more like what we are looking for but again, we just don’t know because the specs ARE NOT CLEAR. -That means we are guessing and guessing is NEVER good in programming..

21 Glide Will move to a specific x and y location on the screen Will take however long you specify to get there. You can make the Sprite go very slow or very fast.

22 What you Learned Specs (or program instructions) need to be specific and leave as little room for confusion as possible. In programming there is almost always more than one way to accomplish the same task. How to move your sprites using go to, move, and glide.

23 Programming Challenge If you are finished early please accept this programming challenge. In the last example that uses glide you may have noticed that the only time Sprite1 was facing the correct direction was when he was moving across the screen towards the right. See if you can find a way to make him point in the right direction when he is moving to the right or to the left. – Hint: You will need to create a new costume for this. – If you accomplish this task it is worth 5 extra credit points.

24 Extra Challenges Make your sprite do a 360 degree rotation each time he/she hits a corner of the rectangle. Make your sprite SHRINKS by 30 units each time it hits the bottom right corner Make sure it gets resized back to ‘normal’ when it reaches the top left corner (where it started)


Download ppt "Moving Around in Scratch The Basics… -You do want to have Scratch open as you will be creating a program. -Follow the instructions and if you have questions."

Similar presentations


Ads by Google