Skip to content

Please update your browser

Your browser version is not supported by this site. CS First may not work properly. Learn more

arrow_back Drawing and Animating a Lightning Bolt

Transcript

In this add-on you will draw and program a user-controlled lightning bolt that moves from the sky to the ground.

To begin, you'll need to draw a lightning bolt.

Click paint new sprite.

Click the paintbrush and choose a color and line width for your lightning.

Then, create a lightning bolt.

Don't worry if it isn't perfect, you can always go back and edit it later.

If you make a mistake while drawing, you can click the undo button at the top of the paint editor.

Once you've created a lightning bolt, program it to move from the sky to the ground.

First program a starting position for the sprite.

Drag the lightning bolt to a starting position at the top of the stage.

Then drag out a go-to block from the motion menu.

The x and y coordinates in the block will automatically match the lightning bolts current position.

So if you move the sprite, then click the block, the bolt will return to that starting position.

Now the lightning bolt should glide towards the ground.

Drag the lightning bolt to where you'd like it to glide to.

Then drag out a glide for one second block, and attach it below the go-to block.

Click this block stack to try it.

Great, now the lightning starts at the top of the screen and glides to the bottom.

Tinker with the time value in the glide block to get the lightning moving in a speed that you like.

Click events and find an event to run this code.

As example, we'll use when space key pressed, but you can use any event or broadcast message you like for your story.

Try it out.

Great, when the space key is pressed, the lightning moves.

There are a few things that you can do now to make this a little more realistic looking.

Consider hiding the lightning after it moves down and showing it immediately after your event.

Then the sprite will hide between strikes.

You might also want to create a second costume for your lightning sprite so that it changes its appearance after is glides to look like it had struck the ground.

Now it's your turn.

First, click paint your sprite.

Second, paint a lightning bolt.

Third, select a starting position with a go-to block.

Fourth, program the sprite to glide to a position.

Fifth, and finally, start your code with an event.

Then considering hiding your sprite between strikes and creating a second costume for when the sprite glides to the ground.

Choose an Add-On
Lightning Reaction
In this add-on, you’ll program the characters in your story to react when the lightning strikes.
Drawing and Animating a Lightning Bolt
In this add-on, you’ll draw and program a user-controlled lightning bolt that moves from the sky to the ground.
Sun Comes Out
In this add-on, you’ll program a second scene for your rainy day story.
Playing Thunder
In this add-on, you’ll play thunder and rain sounds in your story.
Earthquake
In this add-on, you’ll broadcast an earthquake to really shake up your story.
Code a Rainbow
Draw and program a rainbow to appear in your rainy day story!
arrow_backward Back
Next arrow_forward
Instructions
  1. Choose an Add-On, and click "watch" to learn how to build it.
  2. Once you finish one Add-On, try another one below the video!