CatWalkproject Part 2 PDF
CatWalkproject Part 2 PDF
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
L1 R2 CatWalkproject
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
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