Pygame is a Python wrapper for SDL – a cross-platform C library for controlling multimedia –, written by Pete Shinners. This means, using pygame, you can write video games or other multimedia applications in Python that will run unaltered on any of SDL’s supported platforms (Windows, Unix, Mac, beOS and others).
This section provides an overview of what pygame is, and why a developer might want to use it.
It should also mention any large subjects within pygame, and link out to the related topics. Since the Documentation for pygame is new, you may need to create initial versions of those related topics.
flag
arguments are:flag | description |
---|---|
pygame.FULLSCREEN | window is fullscreen |
pygame.RESIZABLE | window is resizeable |
pygame.NOFRAME | window has no border or controls |
pygame.DOUBLEBUF | use double buffer - recommended for HWSURFACE or OPENGL |
pygame.HWSURFACE | window is hardware accelerated, only possible in combination with FULLSCREEN |
pygame.OPENGL | window is renderable by OpenGL |
Other remarks:
Pygame can currently only handle one single window at a time. Creating a second window by calling pygame.display.set_mode((x,y))
a second time will close the first window.
Changing the depths
argument is almost never required - pygame will select the best one by itself. In case a depth that is not supported by the system is set, pygame will emulate this depth, which can be very slow.
Things that are drawn onto the surface returned by pygame.display.set_mode()
are not immediately visible on screen - the display first has to be flipped using pygame.display.update()
or pygame.display.flip()
.
If you want to have other colours as the background, then name a new variable such as red = (255,0,0)
and change the display.fill(black)
to display.fill(red)
. You can create colours by storing them in a variable and checking their RGB values from the internet.
Try to play music in '.wav' instead of '.mp3'.In '.mp3' the music lags.