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

III. Mr. Stick Man Races for the Exit > 17. Creating Mr. Stick Man

Chapter 17. Creating Mr. Stick Man

In this chapter, we’ll create the main character of our Mr. Stick Man Races for the Exit game. This will require the most complicated coding we’ve done so far, because Mr. Stick Man needs to run left and right, jump, stop when he runs into a platform, and fall when he runs off the edge of a platform. We’ll use event bindings for the left and right arrow keys to make the stick figure run left and right, and we’ll have him jump when the player presses the spacebar.

Initializing the Stick Figure

The __init__ function for our new stick figure class will look a lot like it does in the other classes in our game so far. We start by giving our new class a name: StickFigureSprite. As with previous classes, this class has a parent class: Sprite.


  

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