INTRODUCTION TO RANDOM Numbers
We can generate a random number in Scratch between any two numbers. For example, when we use the block below Scratch will randomly pick either 1, 2, 3, 4, 5, 6, 7, 8, 9, or 10.
This block (with the round edges) is a reporter block, that provides a value. We can use this block inside of other blocks that take a value.
We can use the blocks above to make a character move around the screen randomly!
Random – Movement
Exercise: Make a character move RANdomly
Make your character move around randomly but still stay within 100 pixels in the x and y direction of the center of the screen (0,0).
- If they are below y = -100 point they shouldn’t go any lower.
- If they are above y = 100 they shouldn’t go any higher.
- If they are to the left of x = -100 they shouldn’t go any farther left.
- If they are to the right of x = 100 they shouldn’t go any farther right.
These pieces might be helpful:
Hint: Point in direction might be helpful too!