Using MIT Scratch for Programming and Control Exercise

  • Slides: 9
Download presentation
Using MIT Scratch for Programming and Control Exercise 2 Controlling movement with the keyboard

Using MIT Scratch for Programming and Control Exercise 2 Controlling movement with the keyboard Year 9 ICT Autumn Term 2007

What you will learn • In this exercise we will learn: – how to

What you will learn • In this exercise we will learn: – how to control the movement of the sprite with the keyboard arrows using x and y coordinates – We can combine this with the previous exercise to make the sprite walk around the screen

Keyboard control • It is possible to control your sprite using the keyboard arrow

Keyboard control • It is possible to control your sprite using the keyboard arrow keys. • There is a small pointer next to the Sprite symbol at the top of the screen which can be set to any angle thereby determining the natural direction of movement of the sprite. • In this exercise we want the Sprite to move exactly up and down vertically or side to side horizontally so we will use the change x by and change y by instructions to order to ensure that the Sprite moves exactly horizontally or vertically

Keyboard control • Before completing this exercise dump your existing script into the left

Keyboard control • Before completing this exercise dump your existing script into the left had side of the screen (this will delete it)

Keyboard control • Now copy the main part of the script then edit the

Keyboard control • Now copy the main part of the script then edit the sub script for each movement of the mouse determined by each of the respective four arrow keys

Keyboard control • Drop the three new copied sets of instructions inside the forever

Keyboard control • Drop the three new copied sets of instructions inside the forever instruction (not inside the existing If condition instruction) • Click the green flag button. • It should now be possible to drive your cat sprite around the screen using the up, down, left and right arrow keys

Keyboard control

Keyboard control

Cat walking with keyboard control • Looking back over the previous exercises it should

Cat walking with keyboard control • Looking back over the previous exercises it should be possible to make a script combining what you have already learned that allows the Cat sprite to walk around the screen.

Save your work • Save this exercise with the file name catwalk 2

Save your work • Save this exercise with the file name catwalk 2