pygame
A lot of Ren'Py internals depend on a vendored reimplementation of the
pygame API, built on top of SDL. It is accessible as the renpy.pygame
package:
from renpy import pygame
When Ren'Py starts, this package is also registered under the pygame
and pygame_sdl2 names, so import pygame also works inside game
code.
Compatibility
Ren'Py's pygame tries to be compatible with the non-deprecated public API of the pygame-ce project. If some things are missing, you can file a feature request to have them added.
At the same time, Ren'Py's pygame adds extra things beyond the pygame
API, but those are considered an implementation detail. If you need some
non-standard API to be accessible, you can file a feature request to have
it exposed through the renpy namespace.
Submodules
The following submodules are available. Note that the Surface and
Rect classes are also available directly from the package root.
colorThe Color class and named colors.
constantsEvent types and other constants. The same constants are also available as
locals, and directly in therenpy.pygamenamespace.controllerGame controller support.
displayDisplay and window initialization and management.
drawDrawing shapes, such as rectangles, polygons, circles and lines, onto surfaces.
eventAccess to the event queue.
gfxdrawAntialiased drawing primitives.
imageLoading and saving images. For example,
pygame.image.savecan save a surface to a PNG file.joystickJoystick support.
keyKeyboard state.
mouseMouse state.
powerPower state information.
rectThe Rect class.
scrapClipboard access.
surfaceThe Surface class.
timeTime-related functions, including the
Clockclass.transformSurface transformations, such as scaling, rotation and flipping.