Uploaded by NT H

Scratch Programming in Easy Steps, 2nd Edition Upd... ---- (2 Drawing with Scratch) (1)

advertisement
Using directions to move
As you saw last chapter, there is another way you can move sprites in Scratch, which is to
point them in a particular direction and then move them forwards in that direction.
The direction numbers go from -179 to 180. Up is direction 0, down is 180, left is -90 and
right is 90. See the compass diagram on the right.
Which is better? Moving using coordinates, or using directions? There’s no right
answer to that: it depends on your project. Part of the art of Scratch is to choose the
best approach for each project you write. We’ll use both methods in this book,
sometimes in the same program.
Here are the blocks you use to move using directions:
Copyright © 2019. In Easy Steps Limited. All rights reserved.
• move 10 steps: This moves your sprite forwards. In the case of the cat, this usually means
the direction it’s facing. You can change the number of steps, and a negative number
makes the sprite go backwards.
• turn clockwise 15 degrees: This rotates your sprite clockwise by 15 degrees. You can
change the number of degrees. You can use a negative number to turn the other way, but
you will rarely need to, because of the next block.
• turn counter-clockwise 15 degrees: This block turns your sprite in the other direction.
• point towards: This block is used to point a sprite towards another sprite, or the mouse
pointer.
• point in direction 90: This makes your sprite point in a particular direction. There is a
dial control you can use to choose a direction (see right). You can also type in a number
McManus, S 2019, Scratch Programming in Easy Steps, 2nd Edition : Updated for Scratch 3, In Easy Steps Limited, Leamington Spa. Available from: ProQuest Ebook Central. [7 June 2023].
Created from khalifa on 2023-06-07 13:09:07.
of your choice, such as 90 for right, or 0 for up.
Copyright © 2019. In Easy Steps Limited. All rights reserved.
When you turn your sprite, Scratch makes sure the numbers make sense
automatically. For example, when the direction is 180 (down) and you rotate
clockwise by 90 degrees, Scratch turns the resulting direction into -90 (left) instead
of 270, which would be mathematically correct, but is outside the range of directions
Scratch uses.
McManus, S 2019, Scratch Programming in Easy Steps, 2nd Edition : Updated for Scratch 3, In Easy Steps Limited, Leamington Spa. Available from: ProQuest Ebook Central. [7 June 2023].
Created from khalifa on 2023-06-07 13:09:07.
Download