Skip to content

Please update your browser

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

5. Partita persa

Transcript

In this video, you will program the backdrop to show “game over” if the sprite touches an obstacle. First, select the racer sprite. The game ends *if* the racer sprite touches an obstacle. From the “control” menu, drag out an “if then” block, and add it to the forever loop. Remember, an “if then” block checks if something is true, then performs an action if it is. To check if the sprite is touching an obstacle, add a “touching” block from the “sensing” menu to the “if then” block. Choose the obstacle sprite from the dropdown menu.

Then, open the “looks” menu and add a “switch backdrop to” block to the “if then” block. Choose the “game over” backdrop from the dropdown menu.

Test your code. If the racer touches an obstacle, the backdrop switches to display “game over.”

Try playing the game again. The backdrop still says “game over,” but the game hasn’t even started! To fix this, add a “switch backdrop to” block right after the “when flag clicked” block, and select the starting backdrop from the dropdown menu.

Test the code by clicking the flag. The game starts with a backdrop, and switches to the “game over” backdrop only when it hits an obstacle.

Here’s the game plan: Make the backdrop show “game over” if the racer touches an obstacle using an “if then” block, a “touching” block, and a “switch backdrop to” block.

arrow_backward Indietro
Avanti arrow_forward
Istruzioni
Quando lo skater tocca un ostacolo, fai comparire sullo schermo la scritta "game over", usando i blocchi "Se-allora", "Sta toccando" e "Passa allo sfondo".