0% found this document useful (0 votes)
271 views

CatWalkproject Part 2 PDF

This document provides instructions for using keyboard arrows to control the movement of a sprite in Scratch. It describes copying an if/then script block multiple times to create separate movement scripts for up, down, left and right arrow keys. Each copy is then edited to set the correct arrow key, direction, and change in y or x value to move the sprite vertically or horizontally when that key is pressed. The completed script allows driving a cat sprite around the screen using the arrow keys.

Uploaded by

MrMJSmith
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
271 views

CatWalkproject Part 2 PDF

This document provides instructions for using keyboard arrows to control the movement of a sprite in Scratch. It describes copying an if/then script block multiple times to create separate movement scripts for up, down, left and right arrow keys. Each copy is then edited to set the correct arrow key, direction, and change in y or x value to move the sprite vertically or horizontally when that key is pressed. The completed script allows driving a cat sprite around the screen using the arrow keys.

Uploaded by

MrMJSmith
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Scratch Cat Walk Project

Using the keyboard to control your sprite (using if condition instruction)

It is possible to control your sprite using the mouse 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 the correct movement of the Sprite Before completing this exercise dump your existing script into the left had side of the screen (this will delete it) Start a new script with the when green flag pressed and forever instructions Choose the if condition instruction and drag in the key pressed

instruction from the sensing topics. Set the key pressed to down arrow

Add the point in direction and change y by set instructions Set point in direction to 180 and change y by to -10

We will 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

Click on the copy (stamp symbol) tool then click on the word if in the script. This will create a copy of that part of the script. Repeat this process twice more in order to create the scripts for each different

movement of the sprite

L1 R2 CatWalkproject

Scratch Cat Walk Project


Drop the three new copied sets of instructions inside the forever instruction (not inside the existing If condition instruction)

Set the key pressed to up arrow Set the point in direction to 0 Set the change y by to 10

Set the key pressed to right arrow Set the point in direction to 90 Set the change y by to 10

Set the key pressed to left arrow Set the point in direction to -90 Set the change y by to -10

Click the green flag button. It should now be possible to drive your cat sprite around the screen using the arrow keys

L1 R2 CatWalkproject

Scratch Cat Walk Project


cat walking with keyboard control Looking back over exercise 4 and 5 it should be possible to make a script combining what you have already learned that allows the Cat sprite to walk around the screen.

Note that two scripts have been created here as an expedience for display purposes and it is possible to combine all of this into one script

L1 R2 CatWalkproject

You might also like