arrow_back 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. To begin, you’ll need to draw a lightning bolt.
Click “Paint new sprite.” Select “vector mode," as it’s generally easier to edit vector images. Click the paint brush, 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 match the lightning bolt’s 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 1 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 at a speed you like.
Click "events," and find an event to run this code. This example will use “when space key pressed,” but you can use any event you’d 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 look a little more realistic. 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 the lightning sprite, so it changes its appearance after it glides to look like it struck the ground.
Now, it’s your turn: 1) Click “paint new sprite.” 2) Paint a lightning bolt.
3) Select a starting position with a “go to” block.
4) Program the sprite to glide to a position. 5) Start your code with an event.
Then: Consider hiding the sprite between strikes and creating a second costume for when the sprite glides to the ground.