Free Trial

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

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

9. Games and Animation! > Time for action—throwing blocks to Bash the Alien!

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).

Time for action—throwing blocks to Bash the Alien!

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).
    Time for action—throwing blocks to Bash the Alien!

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint