Index - Pygame Documentation

pygame documentation | || Pygame Home || Help Contents || Reference Index || Cdrom || Color || Cursors || Display || Draw || Event || Font || Image || Joystick || Key || Mask || Mixer || Mouse || Movie || Music || Overlay || Pixelarray || Pygame || Rect || Scrap || Sndarray || Sprite || Surface || Surfarray || Time || Transform

- pygame - the top level pygame package

- pygame.error - standard pygame exception
- pygame.get_error - get the current error message
- pygame.get_sdl_byteorder - get the byte order of SDL
- pygame.get_sdl_version - get the version number of SDL
- pygame.init - initialize all imported pygame modules
- pygame.cdrom - pygame module for audio cdrom control

- pygame.cdrom.CD - class to manage a cdrom drive

- CD.eject - eject or open the cdrom drive
- CD.get_all - get all track information
- CD.get_busy - true if the drive is playing audio
- CD.get_current - the current audio playback position
- CD.get_empty - False if a cdrom is in the drive
- CD.get_id - the index of the cdrom drive
- CD.get_init - true if this cd device initialized
- CD.get_name - the system name of the cdrom drive
- CD.get_numtracks - the number of tracks on the cdrom
- CD.get_paused - true if the drive is paused
- CD.get_track_audio - true if the cdrom track has audio data
- CD.get_track_length - length of a cdrom track
- CD.get_track_start - start time of a cdrom track
- CD.init - initialize a cdrom drive for use
- CD.pause - temporarily stop audio playback
- CD.play - start playing audio
- CD.quit - uninitialize a cdrom drive for use
- CD.resume - unpause audio playback
- CD.stop - stop audio playback

- pygame.cdrom.get_count - number of cd drives on the system
- pygame.cdrom.get_init - true if the cdrom module is initialized
- pygame.cdrom.init - initialize the cdrom module
- pygame.cdrom.quit - uninitialize the cdrom module

- pygame.Color - pygame object for color representations

- Color.a - Gets or sets the alpha value of the Color.
- Color.b - Gets or sets the blue value of the Color.
- Color.cmy - Gets or sets the CMY representation of the Color.
- Color.correct_gamma - Applies a certain gamma value to the Color.
- Color.g - Gets or sets the green value of the Color.
- Color.hsla - Gets or sets the HSLA representation of the Color.
- Color.hsva - Gets or sets the HSVA representation of the Color.
- Color.i1i2i3 - Gets or sets the I1I2I3 representation of the Color.
- Color.normalize - Returns the normalized RGBA values of the Color.
- Color.r - Gets or sets the red value of the Color.

- pygame.cursors - pygame module for cursor resources

- pygame.cursors.compile - create binary cursor data from simple strings
- pygame.cursors.load_xbm - load cursor data from an xbm file

- pygame.display - pygame module to control the display window and screen

- pygame.display.flip - update the full display Surface to the screen
- pygame.display.get_active - true when the display is active on the display
- pygame.display.get_caption - get the current window caption
- pygame.display.get_driver - get the name of the pygame display backend
- pygame.display.get_init - true if the display module is initialized
- pygame.display.get_surface - get a reference to the currently set display surface
- pygame.display.get_wm_info - Get information about the current windowing system
- pygame.display.gl_get_attribute - get the value for an opengl flag for the current display
- pygame.display.gl_set_attribute - request an opengl display attribute for the display mode
- pygame.display.iconify - iconify the display surface
- pygame.display.Info - Create a video display information object
- pygame.display.init - initialize the display module
- pygame.display.list_modes - get list of available fullscreen modes
- pygame.display.mode_ok - pick the best color depth for a display mode
- pygame.display.quit - uninitialize the display module
- pygame.display.set_caption - set the current window caption
- pygame.display.set_gamma - change the hardware gamma ramps
- pygame.display.set_gamma_ramp - set_gamma_ramp(red, green, blue): return bool
- pygame.display.set_icon - change the system image for the display window
- pygame.display.set_mode - initialize a window or screen for display
- pygame.display.set_palette - set the display color palette for indexed displays
- pygame.display.toggle_fullscreen - switch between fullscreen and windowed displays
- pygame.display.update - update portions of the screen for software displays

- pygame.draw - pygame module for drawing shapes

- pygame.draw.aaline - draw fine antialiased lines
- pygame.draw.aalines - pygame.draw.aalines(Surface, color, closed, pointlist, blend=1): return Rect
- pygame.draw.arc - draw a partial section of an ellipse
- pygame.draw.circle - draw a circle around a point
- pygame.draw.ellipse - draw a round shape inside a rectangle
- pygame.draw.line - draw a straight line segment
- pygame.draw.lines - draw multiple contiguous line segments
- pygame.draw.polygon - draw a shape with any number of sides
- pygame.draw.rect - draw a rectangle shape

- pygame.event - pygame module for interacting with events and queues

- pygame.event.clear - remove all events from the queue
- pygame.event.Event - create a new event object
- pygame.event.event_name - get the string name from and event id
- pygame.event.get - get events from the queue
- pygame.event.get_blocked - test if a type of event is blocked from the queue
- pygame.event.get_grab - test if the program is sharing input devices
- pygame.event.peek - test if event types are waiting on the queue
- pygame.event.poll - get a single event from the queue
- pygame.event.post - place a new event on the queue
- pygame.event.pump - internally process pygame event handlers
- pygame.event.set_allowed - control which events are allowed on the queue
- pygame.event.set_blocked - control which events are allowed on the queue
- pygame.event.set_grab - control the sharing of input devices with other applications
- pygame.event.wait - wait for a single event from the queue

- pygame.font - pygame module for loading and rendering fonts

- pygame.font.Font - create a new Font object from a file

- Font.get_ascent - get the ascent of the font
- Font.get_bold - check if text will be rendered bold
- Font.get_descent - get the descent of the font
- Font.get_height - get the height of the font
- Font.get_italic - check if the text will be rendered italic
- Font.get_linesize - get the line space of the font text
- Font.get_underline - check if text will be rendered with an underline
- Font.metrics - Gets the metrics for each character in the pased string.
- Font.render - draw text on a new Surface
- Font.set_bold - enable fake rendering of bold text
- Font.set_italic - enable fake rendering of italic text
- Font.set_underline - control if text is rendered with an underline
- Font.size - determine the amount of space needed to render text

- pygame.font.get_default_font - get the filename of the default font
- pygame.font.get_fonts - get all available fonts
- pygame.font.get_init - true if the font module is initialized
- pygame.font.init - initialize the font module
- pygame.font.match_font - find a specific font on the system
- pygame.font.quit - uninitialize the font module
- pygame.font.SysFont - create a Font object from the system fonts

- pygame.image - pygame module for image transfer

- pygame.image.frombuffer - create a new Surface that shares data inside a string buffer
- pygame.image.fromstring - create new Surface from a string buffer
- pygame.image.get_extended - test if extended image formats can be loaded
- pygame.image.load - load new image from a file
- pygame.image.save - save an image to disk
- pygame.image.tostring - transfer image to string buffer

- pygame.joystick - pygame module for interacting with joystick devices

- pygame.joystick.get_count - number of joysticks on the system
- pygame.joystick.get_init - true if the joystick module is initialized
- pygame.joystick.init - initialize the joystick module
- pygame.joystick.Joystick - create a new Joystick object

- Joystick.get_axis - get the current position of an axis
- Joystick.get_ball - get the relative position of a trackball
- Joystick.get_button - get the current button state
- Joystick.get_hat - get the position of a joystick hat
- Joystick.get_id - get the Joystick ID
- Joystick.get_init - check if the Joystick is initialized
- Joystick.get_name - get the Joystick system name
- Joystick.get_numaxes - get the number of axes on a Joystick
- Joystick.get_numballs - get the number of trackballs on a Joystick
- Joystick.get_numbuttons - get the number of buttons on a Joystick
- Joystick.get_numhats - get the number of hat controls on a Joystick
- Joystick.init - initialize the Joystick
- Joystick.quit - uninitialize the Joystick

- pygame.joystick.quit - uninitialize the joystick module

- pygame.key - pygame module to work with the keyboard

- pygame.key.get_focused - true if the display is receiving keyboard input from the system
- pygame.key.get_mods - determine which modifier keys are being held
- pygame.key.get_pressed - get the state of all keyboard buttons
- pygame.key.get_repeat - see how held keys are repeated
- pygame.key.name - get the name of a key identifier
- pygame.key.set_mods - temporarily set which modifier keys are pressed
- pygame.key.set_repeat - control how held keys are repeated

- pygame.mask - pygame module for image masks.

- pygame.mask.from_surface - Returns a Mask from the given surface.
- pygame.mask.Mask - pygame object for representing 2d bitmasks

- Mask.get_at - Returns nonzero if the bit at (x,y) is set.
- Mask.get_bounding_rects - Returns a list of bounding rects of regions of set pixels.
- Mask.get_size - Returns the size of the mask.
- Mask.overlap - Returns the point of intersection if the masks overlap with the given offset - or None if it does not overlap.
- Mask.overlap_area - Returns the number of overlapping 'pixels'.
- Mask.set_at - Sets the position in the mask given by x and y.

- pygame.mixer - pygame module for loading and playing sounds

- pygame.mixer.Channel - Create a Channel object for controlling playback

- Channel.fadeout - stop playback after fading channel out
- Channel.get_busy - check if the channel is active
- Channel.get_endevent - get the event a channel sends when playback stops
- Channel.get_queue - return any Sound that is queued
- Channel.get_sound - get the currently playing Sound
- Channel.get_volume - get the volume of the playing channel
- Channel.pause - temporarily stop playback of a channel
- Channel.play - play a Sound on a specific Channel
- Channel.queue - queue a Sound object to follow the current
- Channel.set_endevent - have the channel send an event when playback stops
- Channel.set_volume - set the volume of a playing channel
- Channel.stop - stop playback on a Channel
- Channel.unpause - resume pause playback of a channel

- pygame.mixer.fadeout - fade out the volume on all sounds before stopping
- pygame.mixer.find_channel - find an unused channel
- pygame.mixer.get_busy - test if any sound is being mixed
- pygame.mixer.get_init - test if the mixer is initialized
- pygame.mixer.get_num_channels - get the total number of playback channels
- pygame.mixer.init - initialize the mixer module
- pygame.mixer.pause - temporarily stop playback of all sound channels
- pygame.mixer.pre_init - preset the mixer init arguments
- pygame.mixer.music - pygame module for controlling streamed audio

- pygame.mixer.music.fadeout - stop music playback after fading out
- pygame.mixer.music.get_busy - check if the music stream is playing
- pygame.mixer.music.get_endevent - get the event a channel sends when playback stops
- pygame.mixer.music.get_pos - get the music play time
- pygame.mixer.music.get_volume - get the music volume
- pygame.mixer.music.load - Load a music file for playback
- pygame.mixer.music.pause - temporarily stop music playback
- pygame.mixer.music.play - Start the playback of the music stream
- pygame.mixer.music.queue - queue a music file to follow the current
- pygame.mixer.music.rewind - restart music
- pygame.mixer.music.set_endevent - have the music send an event when playback stops
- pygame.mixer.music.set_volume - set the music volume
- pygame.mixer.music.stop - stop the music playback
- pygame.mixer.music.unpause - resume paused music

- pygame.mixer.quit - uninitialize the mixer
- pygame.mixer.set_num_channels - set the total number of playback channels
- pygame.mixer.set_reserved - reserve channels from being automatically used
- pygame.mixer.Sound - Create a new Sound object from a file

- Sound.fadeout - stop sound playback after fading out
- Sound.get_buffer - acquires a buffer object for the sameples of the Sound.
- Sound.get_length - get the length of the Sound
- Sound.get_num_channels - count how many times this Sound is playing
- Sound.get_volume - get the playback volume
- Sound.play - begin sound playback
- Sound.set_volume - set the playback volume for this Sound
- Sound.stop - stop sound playback

- pygame.mixer.stop - stop playback of all sound channels
- pygame.mixer.unpause - resume paused playback of sound channels

- pygame.mouse - pygame module to work with the mouse

- pygame.mouse.get_cursor - get the image for the system mouse cursor
- pygame.mouse.get_focused - check if the display is receiving mouse input
- pygame.mouse.get_pos - get the mouse cursor position
- pygame.mouse.get_pressed - get the state of the mouse buttons
- pygame.mouse.get_rel - get the amount of mouse movement
- pygame.mouse.set_cursor - set the image for the system mouse cursor
- pygame.mouse.set_pos - set the mouse cursor position
- pygame.mouse.set_visible - hide or show the mouse cursor

- pygame.movie - pygame module for playback of mpeg video

- pygame.movie.Movie - load an mpeg movie file

- Movie.get_busy - check if the movie is currently playing
- Movie.get_frame - get the current video frame
- Movie.get_length - the total length of the movie in seconds
- Movie.get_size - get the resolution of the video
- Movie.get_time - get the current vide playback time
- Movie.has_audio - check if the movie file contains audio
- Movie.has_video - check if the movie file contains video
- Movie.pause - temporarily stop and resume playback
- Movie.play - start playback of a movie
- Movie.render_frame - set the current video frame
- Movie.rewind - restart the movie playback
- Movie.set_display - set the video target Surface
- Movie.set_volume - set the audio playback volume
- Movie.skip - advance the movie playback position
- Movie.stop - stop movie playback

- pygame.Overlay - pygame object for video overlay graphics

- Overlay.display - set the overlay pixel data
- Overlay.get_hardware - test if the Overlay is hardware accelerated
- Overlay.set_location - control where the overlay is displayed

- pygame.PixelArray - pygame object for direct pixel access of surfaces

- PixelArray.compare - Compares the PixelArray with another one.
- PixelArray.extract - Extracts the passed color from the PixelArray.
- PixelArray.make_surface - Creates a new Surface from the current PixelArray.
- PixelArray.replace - Replaces the passed color in the PixelArray with another one.
- PixelArray.surface - Gets the Surface the PixelArray uses.

- pygame.Rect - pygame object for storing rectangular coordinates

- Rect.clamp - moves the rectangle inside another
- Rect.clamp_ip - moves the rectangle inside another, in place
- Rect.clip - crops a rectangle inside another
- Rect.collidedict - test if one rectangle in a dictionary intersects
- Rect.collidedictall - test if all rectangles in a dictionary intersect
- Rect.collidelist - test if one rectangle in a list intersects
- Rect.collidelistall - test if all rectangles in a list intersect
- Rect.collidepoint - test if a point is inside a rectangle
- Rect.colliderect - test if two rectangles overlap
- Rect.contains - test if one rectangle is inside another
- Rect.fit - resize and move a rectangle with aspect ratio
- Rect.inflate - grow or shrink the rectangle size
- Rect.inflate_ip - grow or shrink the rectangle size, in place
- Rect.move - moves the rectangle
- Rect.move_ip - moves the rectangle, in place
- Rect.normalize - correct negative sizes
- Rect.union - joins two rectangles into one
- Rect.union_ip - joins two rectangles into one, in place
- Rect.unionall - the union of many rectangles
- Rect.unionall_ip - the union of many rectangles, in place

- pygame.scrap - pygame module for clipboard support.

- pygame.scrap.contains - Checks, whether a certain type is available in the clipboard.
- pygame.scrap.get - Gets the data for the specified type from the clipboard.
- pygame.scrap.get_types - Gets a list of the available clipboard types.
- pygame.scrap.init - Initializes the scrap module.
- pygame.scrap.lost - Checks whether the clipboard is currently owned by the application.
- pygame.scrap.put - Places data into the clipboard.
- pygame.scrap.set_mode - Sets the clipboard access mode.

- pygame.sndarray - pygame module for accessing sound sample data

- pygame.sndarray.array - copy Sound samples into an array
- pygame.sndarray.get_arraytype - Gets the currently active array type.
- pygame.sndarray.get_arraytypes - Gets the array system types currently supported.
- pygame.sndarray.make_sound - convert an array into a Sound object
- pygame.sndarray.samples - reference Sound samples into an array
- pygame.sndarray.use_arraytype - Sets the array system to be used for sound arrays

- pygame.sprite - pygame module with basic game object classes

- pygame.sprite.collide_circle - collision detection between two sprites, using circles.
- pygame.sprite.collide_circle_ratio - collision detection between two sprites, using circles scaled to a ratio.
- pygame.sprite.collide_mask - collision detection between two sprites, using masks.
- pygame.sprite.collide_rect - collision detection between two sprites, using rects.
- pygame.sprite.collide_rect_ratio - collision detection between two sprites, using rects scaled to a ratio.
- pygame.sprite.DirtySprite - a more featureful subclass of Sprite with more attributes

- pygame.sprite.Group - container class for many Sprites

- Group.add - add Sprites to this Group
- Group.clear - draw a background over the Sprites
- Group.copy - duplicate the Group
- Group.draw - blit the Sprite images
- Group.empty - remove all Sprites
- Group.has - test if a Group contains Sprites
- Group.remove - remove Sprites from the Group
- Group.sprites - list of the Sprites this Group contains
- Group.update - call the update method on contained Sprites

- pygame.sprite.groupcollide - find all Sprites that collide between two Groups
- pygame.sprite.GroupSingle - Group container that holds a single Sprite
- pygame.sprite.LayeredDirty - LayeredDirty Group is for DirtySprites. Subclasses LayeredUpdates.

- LayeredDirty.change_layer - changes the layer of the sprite
- LayeredDirty.clear - used to set background
- LayeredDirty.draw - draw all sprites in the right order onto the passed surface.
- LayeredDirty.get_clip - clip the area where to draw. Just pass None (default) to reset the clip
- LayeredDirty.repaint_rect - repaints the given area
- LayeredDirty.set_clip - clip the area where to draw. Just pass None (default) to reset the clip
- LayeredDirty.set_timing_treshold - sets the treshold in milliseconds

- pygame.sprite.LayeredUpdates - LayeredUpdates Group handles layers, that draws like OrderedUpdates.

- LayeredUpdates.add - add a sprite or sequence of sprites to a group
- LayeredUpdates.change_layer - changes the layer of the sprite
- LayeredUpdates.draw - draw all sprites in the right order onto the passed surface.
- LayeredUpdates.get_bottom_layer - returns the bottom layer
- LayeredUpdates.get_layer_of_sprite - returns the layer that sprite is currently in.
- LayeredUpdates.get_sprite - returns the sprite at the index idx from the groups sprites
- LayeredUpdates.get_sprites_at - returns a list with all sprites at that position.
- LayeredUpdates.get_sprites_from_layer - returns all sprites from a layer, ordered by how they where added
- LayeredUpdates.get_top_layer - returns the top layer
- LayeredUpdates.get_top_sprite - returns the topmost sprite
- LayeredUpdates.layers - returns a list of layers defined (unique), sorted from botton up.
- LayeredUpdates.move_to_back - moves the sprite to the bottom layer
- LayeredUpdates.move_to_front - brings the sprite to front layer
- LayeredUpdates.remove_sprites_of_layer - removes all sprites from a layer and returns them as a list.
- LayeredUpdates.sprites - returns a ordered list of sprites (first back, last top).
- LayeredUpdates.switch_layer - switches the sprites from layer1 to layer2

- pygame.sprite.OrderedUpdates - RenderUpdates class that draws Sprites in order of addition
- pygame.sprite.RenderUpdates - Group class that tracks dirty updates

- RenderUpdates.draw - blit the Sprite images and track changed areas

- pygame.sprite.Sprite - simple base class for visible game objects

- Sprite.add - add the sprite to groups
- Sprite.alive - does the sprite belong to any groups
- Sprite.groups - list of Groups that contain this Sprite
- Sprite.kill - remove the Sprite from all Groups
- Sprite.remove - remove the sprite from groups
- Sprite.update - method to control sprite behavior

- pygame.sprite.spritecollide - find Sprites in a Group that intersect another Sprite
- pygame.sprite.spritecollideany - simple test if a Sprite intersects anything in a Group

- pygame.Surface - pygame object for representing images

- Surface.blit - draw one image onto another
- Surface.convert - change the pixel format of an image
- Surface.convert_alpha - change the pixel format of an image including per pixel alphas
- Surface.copy - create a new copy of a Surface
- Surface.fill - fill Surface with a solid color
- Surface.get_abs_offset - find the absolute position of a child subsurface inside its top level parent
- Surface.get_abs_parent - find the top level parent of a subsurface
- Surface.get_alpha - get the current Surface transparency value
- Surface.get_at - get the color value at a single pixel
- Surface.get_bitsize - get the bit depth of the Surface pixel format
- Surface.get_bounding_rect - find the smallest rect containing data
- Surface.get_buffer - acquires a buffer object for the pixels of the Surface.
- Surface.get_bytesize - get the bytes used per Surface pixel
- Surface.get_clip - get the current clipping area of the Surface
- Surface.get_colorkey - Get the current transparent colorkey
- Surface.get_flags - get the additional flags used for the Surface
- Surface.get_height - get the height of the Surface
- Surface.get_locked - test if the Surface is current locked
- Surface.get_locks - Gets the locks for the Surface
- Surface.get_losses - the significant bits used to convert between a color and a mapped integer
- Surface.get_masks - the bitmasks needed to convert between a color and a mapped integer
- Surface.get_offset - find the position of a child subsurface inside a parent
- Surface.get_palette - get the color index palette for an 8bit Surface
- Surface.get_palette_at - get the color for a single entry in a palette
- Surface.get_parent - find the parent of a subsurface
- Surface.get_pitch - get the number of bytes used per Surface row
- Surface.get_rect - get the rectangular area of the Surface
- Surface.get_shifts - the bit shifts needed to convert between a color and a mapped integer
- Surface.get_size - get the dimensions of the Surface
- Surface.get_width - get the width of the Surface
- Surface.lock - lock the Surface memory for pixel access
- Surface.map_rgb - convert a color into a mapped color value
- Surface.mustlock - test if the Surface requires locking
- Surface.set_alpha - set the alpha value for the full Surface image
- Surface.set_at - set the color value for a single pixel
- Surface.set_clip - set the current clipping area of the Surface
- Surface.set_colorkey - Set the transparent colorkey
- Surface.set_masks - set the bitmasks needed to convert between a color and a mapped integer
- Surface.set_palette - set the color palette for an 8bit Surface
- Surface.set_palette_at - set the color for a single index in an 8bit Surface palette
- Surface.set_shifts - sets the bit shifts needed to convert between a color and a mapped integer
- Surface.subsurface - create a new surface that references its parent
- Surface.unlock - unlock the Surface memory from pixel access
- Surface.unmap_rgb - convert a mapped integer color value into a Color

- pygame.surfarray - pygame module for accessing surface pixel data using array interfaces

- pygame.surfarray.array2d - Copy pixels into a 2d array
- pygame.surfarray.array3d - Copy pixels into a 3d array
- pygame.surfarray.array_alpha - Copy pixel alphas into a 2d array
- pygame.surfarray.array_colorkey - Copy the colorkey values into a 2d array
- pygame.surfarray.blit_array - Blit directly from a array values
- pygame.surfarray.get_arraytype - Gets the currently active array type.
- pygame.surfarray.get_arraytypes - Gets the array system types currently supported.
- pygame.surfarray.make_surface - Copy an array to a new surface
- pygame.surfarray.map_array - Map a 3d array into a 2d array
- pygame.surfarray.pixels2d - Reference pixels into a 2d array
- pygame.surfarray.pixels3d - Reference pixels into a 3d array
- pygame.surfarray.pixels_alpha - Reference pixel alphas into a 2d array
- pygame.surfarray.use_arraytype - Sets the array system to be used for surface arrays

- pygame.time - pygame module for monitoring time

- pygame.time.Clock - create an object to help track time

- Clock.get_fps - compute the clock framerate
- Clock.get_rawtime - actual time used in the previous tick
- Clock.get_time - time used in the previous tick
- Clock.tick - update the clock
- Clock.tick_busy_loop - update the clock

- pygame.time.delay - pause the program for an amount of time
- pygame.time.get_ticks - get the time in milliseconds
- pygame.time.set_timer - repeatedly create an event on the event queue
- pygame.time.wait - pause the program for an amount of time

- pygame.transform - pygame module to transform surfaces

- pygame.transform.average_surfaces - find the average surface from many surfaces.
- pygame.transform.chop - gets a copy of an image with an interior area removed
- pygame.transform.flip - flip vertically and horizontally
- pygame.transform.laplacian - find edges in a surface
- pygame.transform.rotate - rotate an image
- pygame.transform.rotozoom - filtered scale and rotation
- pygame.transform.scale - resize to new resolution
- pygame.transform.scale2x - specialized image doubler
- pygame.transform.smoothscale - scale a surface to an arbitrary size smoothly
- pygame.transform.threshold - finds which, and how many pixels in a surface are within a threshold of a color.

- pygame.quit - uninitialize all pygame modules
- pygame.register_quit - register a function to be called when pygame quits
- pygame.version - small module containing version information

- pygame.version.ver - version number as a string
- pygame.version.vernum - tupled integers of the version