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 – increasing ball speed


There are several criteria that we could use to increase the ball speed, such as score or number of hits. However, we're going to increase the ball speed based on the duration of the game. The steps are as follows:

  1. To manipulate the ball speed as the script runs, we'll need a variable. So, create a variable named speed for the ball.

  2. Find the ball script that begins with when I receive (play) and add a set () to () block from the Data palette at the top of the stack. Select the speed variable and give it a starting value of 5.

  3. From the Sensing palette, add a reset timer block. We'll use this block with the understanding that we won't use reset timer anywhere else in the project.

  4. Inside the forever block, add an if () then block.

  5. We're going to evaluate whether or not the timer block is greater than 10 by snapping the () > () block from the Operators palette into the if () block. Then, we will add the timer block from the Sensing palette into the first...