Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL

Chapter 9. Games and Animation! > Time for action throwing blocks to Bash the A... - Pg. 305

Chapter 9 Time for action ­ throwing blocks to Bash the Alien! Along the top of the Blocks Editor main window, we define three global numeric variables. Although each has a different value, that really does not matter--they get new values as the app runs. The three, in order, control invisibility (a nasty little trick the alien has of ducking into hyperspace and emerging at a random location), the score (how many or how few times you manage to tag him), and speed (he changes speed and direction randomly). Next, we add two procedures: 1. MoveAlien does the random stuff. The x and y coordinates of the alien's position change randomly and he zips there at varying speeds. 2. UpdateScore keeps track of how many times he gets touched (darn few, he's a whirling dervish and delights in making us all look like slow, clumsy humans--oh, wait, we are).