Book Image

Scratch 2.0 Beginner's Guide: Second Edition

By : Michael Badger
Book Image

Scratch 2.0 Beginner's Guide: Second Edition

By: Michael Badger

Overview of this book

Table of Contents (18 chapters)
Scratch 2.0 Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – checking for game over


There's going to be more than one way to address our "game over" bug, and that shouldn't surprise you by now. We're going to approach this problem with the forever block.

Let's see what we can do by performing the following steps:

  1. First, detach the first wait until () block from the script and add the forever block in its place.

  2. Add two if () then blocks to the forever block because we will evaluate two unique values.

  3. The first if () then block should evaluate the y position < y position of (paddle) statement.

  4. Add the change (Lives) by (-1) block to the first if () then block we just added.

  5. Make the second if () then block evaluate lives = 0.

  6. Add the stop (all) block to the second if () then block we just added.

  7. Play the game and allow the ball to miss the paddle, and then watch your lives quickly drop to zero. Now, we've found another bug. The following is a screenshot of our current script:

  8. This bug can be overcome by adding a copy of the go to x: ()...