13.5 Summary

In this chapter, we extended our discussion of object-oriented programming by introducing event-driven programming. We used multithreaded event-driven programming to implement a simple video game. We designed our video game by creating classes to represent the components of the game. Functions were tied to mouse clicks and keys presses so that actions would occur when those input events took place. We used timers to place the video game in motion. As part of the implementation, we used inheritance in building turtle objects used in the game. In addition, we used a static variable that could be shared by each object of the class. We also created a static method that did not belong to any object of the class, but could access static data defined in the class.

Key Terms

  • callback function

  • event-driven program

  • event loop

  • mangling

  • multithreaded

  • queue

  • static method

  • static variable

  • thread

Python Keywords and Decorator

  • @staticmethod

Programming Exercises

  1. 13.1   Write your own video game. Here are some simple games to think about:

    •    One-player Pong

    •    One-player Brickout

    •    Frogger

    •    Racetrack

    •    Asteroids

    •    Two-player Pong

    •    Tank battle

    Your game should keep score and utilize each of the callbacks discussed in this chapter.

Design Credits: Calculator Icon made by Smashicons from www.flaticon.com

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.160.43