Pygame.sprite
lastmod 2024-04-09created 2024-04-092 edits
This module is written in Python and contains several high-level classes for managing game objects. Making full use of this module lets you easily manage and draw game objects. The sprite classes are highly optimized, so using the sprite module will likely make your game run faster than without it.
History
The term "sprite" comes from old computers and game consoles. These old boxes could not draw and erase normal graphics fast enough to work as games. These machines had special hardware for handling game-like objects that needed to be animated very quickly. These objects were called "sprites" and had special limitations, but could be drawn and updated very fast. They usually existed in special overlay buffers in the video. These days computers have generally become fast enough to handle sprite-like objects without dedicated hardware. The term sprite is still used to refer to anything animated in 2D games.
Classes
The sprite module has two main classes.
Sprite
The class that should be used as the base class for all game objects. This class does not actually do anything on its own; it just contains several functions that help manage game objects.
Group
The Group class is a container that holds various Sprite objects.