Skip to content

Please update your browser

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

Transcript

Game play is pretty limited in this game, isn’t it? The user can only press the spacebar to move the sprite up. In this add-on, create a button that allows the sprite to dive, or move down faster than it falls. First, you need to program a key that will tell the bird to dive - this example will use the down arrow - and some way to check if the user is pressing that button. If the user is not hitting the spacebar, he or she might be clicking the down arrow. If the user isn’t clicking either, the bird should still move down, just more slowly. This example will remove the “switch costume to parrot b” and “change y by -5” blocks from the else section of this if-else statement, keeping them to the side to use later.

Then, you will add an "if-else" into the "else"where you just removed the code.

Then, add the "key down arrow pressed" block to the inner if-else statement.

If neither the down arrow nor the space bar are pressed, the bird should still move down, so add the “switch costume” and “change y by blocks that you previously removed to the else.

If the down arrow is pressed, however, the bird should move down faster. Tinker with the values to change the speed the sprite falls. This example uses “change y by -10."

This now reads: “If the spacebar key was pressed, change to parrot-b costume and move up 5. Otherwise, if the spacebar key hasn’t been pressed, then check If the down arrow was pressed.

If it was, then switch to costume parrot-a and change y by minus ten. If the down arrow wasn’t pressed, go down more slowly.” Ok. That seems right.

Test the code to see if it works.

Great!

Choisir une extension
Crée ta propre musique
Ajoute un battement de tambour et un fond sonore à ton jeu.
Ajouter une grotte
Dessine un nouveau lutin Grotte avec des bords noirs et ajoute-le à ton jeu.
Augmenter la difficulté du jeu
Oblige le joueur à appuyer continuellement sur la barre d'espace pour garder le lutin en vol.
Parois dangereuses
Fais exploser le lutin Joueur lorsqu'il touche les murs de la grotte.
Ajouter un niveau
Crée des niveaux de jeu supplémentaires qui deviennent de plus en plus rapides et difficiles à mesure que progresse le joueur.
Plonge !
Fais en sorte que le lutin plonge, ou descende plus vite qu'il ne tombe.
arrow_backward Retour
Suivant arrow_forward
Instructions
  1. Clique sur l'une des fenêtres pour accéder à la vidéo de cette extension.
  2. Quand tu as fini, reviens à la fenêtre des extensions et essaies-en une autre !