For Windows, download the pygame-1.9.1.win32-py3.2.msi file. (This is Pygame for Python 3.2 on Windows. If you installed a different version of Python (such as 2.7 or 2.6) download the.msi file for your version of Python.) The current version of Pygame at the time this book was written is 1.9.1. How to install PyGame for Python 3 PyGame is a set of python modules designed for writing games. It uses the SDL library to allow you to create games and multimedia programs in Python. How to use the module. To use the module you first need to import and initialize pygame correctly and set a mode for the display. It's convenient to define color constants in advance, making your code more readable and more beautiful. Pygame is a Python wrapper module for the SDL multimedia library. It contains python functions and classes that will allow you to use SDL’s support for playing cdroms, audio and video output, and keyboard, mouse and joystick input.
Example
Pygame has a module,
pygame.draw , that contains functions which can draw shapes directly to a Surface.
How to use the module
To use the module you first need to import and initialize pygame correctly and set a mode for the display. It's convenient to define color constants in advance, making your code more readable and more beautiful. All functions takes a Surface to draw on, a color and a position argument that's either a pygame Rect or a 2-element integer/float sequence (the
pygame.draw.circle will only take integers because of undefined reasons).
Example
The code below will showcase all the different functions, how they are used and how they look. We'll initialize pygame and define some constants before the examples.
The black color is the Surface default color and represents the part of the Surface that hasn't been drawn onto. The parameters of each function is explained down below at Parameters .
RectPython Pygame DownloadPolygonCircle
The holes is a unfortunate consequence of pygame's drawing algorithm.
Ellipse
The holes is a unfortunate consequence of pygame's drawing algorithm.
ArcHow To Download Pygame ModuleLineLinesAntialiased lineAntialiased linesHow To Install PygameTry it outHow To Download Pygame For Python
Minitab license key. To try it out for yourself: copy one of the code snippets above and the code below in an empty file, change the name image to the name of the Surface you want to blit and experiment.
Pygame Install WindowsComments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |