Project 93: Explosions

2. Make your Target Move Randomly

Use a forever loop and random numbers to make the Target sprite jump around the screen. Make sure your target is waiting after each jump.
Starting point file for this challenge

Your goal

Steps

1. Add our First Code

Add a "when green flag clicked" block from Events.  And attach a "forever" loop from the control tab to it.  Code we put inside of this loop will run forever after we start the game by clicking the green flag.  

2. Set X and Y Coordinates

We'll move our Sprite by changing each of our X and Y coordinates.  Grab "set x to __" and "set y to __"from the blue Motion Tab.  Then clear the numbers inside of the default blocks.  

3. Introduce Random Numbers

Head to the Green Operators tab and add a "pick random 1 to 10" and put it in the "set x to __"  block.  Repeat this process for the "set y to __" block.  

4. Set the Random Values

We'll use -200 to 200 for the Range of our X-Coordinate's Random Values.  Likewise use -150 to 150 for the Y-Coordinate's Values.  This should keep our target in the center region of the screen.

5. Add a delay.

If you've tested the code thus far, you should see your target bouncing far too fast around the screen.  Let's add a delay so we can actually click it.  Head to the control tab and put a "wait __ seconds" block to the bottom of the forever loop.  Then change the number of seconds to 2.