In this video,you will program the rain spriteto repeat moving from the top of the screen to the bottom.
This will make it look like it's raining in your story.
When you look at this example,it might appear as though there are thousandsof little rain sprites,but it's actually one large rain spritethat scrolls from the top to the bottomof the stage and then repeats.
First, set a starting position for the rain.
From the motion menu, select a go to x y block.
Every position on the stage has an x and a y value.
X values determine left and right positions,and y values determine up and down positions.
To see the x and y numbers for any position on the stage,place a sprite on the stage,and read the x y coordinates shown below it.
A go to x y block sets the center of the spriteat the position you typed into the white value blanks.
For example, the top of the stageis y equals 180, so enter 180for the y value and zero for the x.
This will make the sprite go up to the top of the stageand keep its left right positionthe exact middle of the stage.
When you click on this block to test it,you may notice that the rain sprite stilltakes up the entire stage.
That's because it's so huge.
You need to make the sprite start really far out,so it can glide down and look like rain is falling.
Drag out a glide block and attach it to the go to block.
It looks like the bottomof the stage is y equals negative 180.
This is where the middleof the sprite will move to when it glides.
Enter negative 180 into the y spot on the glide block.
Try it out.
Watch it glide by clicking on the block stack.
The rain sprite now starts at the top of the stageand scrolls down to the bottom.
Now you could duplicate this block stack a bunchof times to keep your rainy day going,or you can just program it to repeat.
From the control menu, drag out a forever block.
To tell the computer what action should be repeated,place the forever block around your block stack.
Now the computer will repeat these two blocks forever,or until you tell it to stop.
The sprite will go to the top of the stage,then glide to the bottom,then go to the top of the stage,then glide to the bottom, and so on.
Now it looks like it's raining in your story.
Tinker with the seconds value in the glide blockto change the speed at which the rain is falling.
A longer amount of time will make the rain fall more slowly,and a smaller number will make the rain fall faster.
Finally, add a way for your audience to start this story.
Go to the events menu, choose a when flag clicked event,and place it at the topof this block stack so the story beginswhen the user clicks a flag.
Try it out.
Now it's your turn.
First, add a go to block and set the y value to 180.
Second, add a glide blockand set the y value to negative 180.
Third, make the rain keeps falling with a forever loop.
And fourth, start the code with a when flag clicked block.
In the next step, you will program the lightning flash.