January 2022
Beginner to intermediate
416 pages
10h 21m
English
In this chapter I’ll demonstrate how you can use OOP techniques effectively within the pygame framework. We’ll start off with an example of procedural code, then split that code into a single class and some main code that calls the methods of that class. After that, we’ll build two classes, SimpleButton and SimpleText, that implement basic user interface widgets: a button and a field for displaying text. I’ll also introduce the concept of a callback.
In Chapter 5, we created an old-school screensaver where a ball bounced around inside a window (Listing 5-6, if you need ...