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 Dessiner et animer un éclair

Transcript

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.

Choisir une extension
Réaction face aux éclairs
Dans cette extension, tu vas programmer les personnages dans ton histoire pour qu’ils réagissent lorsque les éclairs frappent.
Dessiner et animer un éclair
Dans cette extension, tu vas dessiner et programmer un éclair contrôlé par l'utilisateur qui glisse du ciel vers le sol.
Le soleil brille
Dans cette extension, tu vas programmer une deuxième scène pour ton histoire sous une journée pluvieuse.
Tonnerre
Dans cette extension, tu vas jouer des sons de tonnerre et de pluie dans ton histoire.
Tremblement de terre
Dans cette extension, tu vas programmer un tremblement de terre pour vraiment secouer ton histoire.
Coder un arc-en-ciel
Dessine un arc-en-ciel et programme son apparition dans ton histoire sous la pluie !
arrow_backward Retour
Suivant arrow_forward
Instructions
  1. Choisis une extension, et clique sur "Regarder" pour découvrir comment la créer.
  2. Une fois que tu as terminé une extension, essayes-en une autre !