Pygame Built in Functions
Pygame Built in Functions
2. Display Functions:
- pygame.display.set_mode(size): Initializes a window or screen for display.
- pygame.display.flip(): Updates the entire screen.
- pygame.display.update(): Updates portions of the screen.
- pygame.display.set_caption(title): Sets the window's title.
- pygame.display.get_surface(): Gets the current display surface object.
3. Event Functions:
- pygame.event.get(): Returns a list of all events currently in the event queue.
- pygame.event.poll(): Retrieves a single event from the queue.
- pygame.event.wait(): Waits for an event to appear in the queue.
- pygame.event.clear(): Clears the event queue.
- pygame.event.post(event): Adds an event to the queue.
4. Drawing Functions:
- pygame.draw.rect(surface, color, rect): Draws a rectangle.
- pygame.draw.circle(surface, color, center, radius): Draws a circle.
- pygame.draw.line(surface, color, start_pos, end_pos): Draws a line.
- pygame.draw.polygon(surface, color, points): Draws a polygon.
5. Surface Functions:
- pygame.Surface(size): Creates a new Surface.
- surface.fill(color): Fills the entire surface with a solid color.
- surface.blit(source, dest): Draws one Surface onto another.
- surface.get_at(pos): Gets the color of the pixel at the pos.
- surface.set_at(pos, color): Sets the color of the pixel at pos.
6. Time Functions:
- pygame.time.Clock(): Creates an object to help control the frame rate.
- clock.tick(framerate): Limits the program to run at a maximum of framerate.
- pygame.time.get_ticks(): Returns the number of milliseconds since Pygame was
initialized.
- pygame.time.delay(milliseconds): Pauses the program for a given number of
milliseconds.
7. Font Functions:
- pygame.font.Font(file, size): Loads a font from the specified file.
- font.render(text, antialias, color): Renders the given text as a Surface.
8. Image Functions:
- pygame.image.load(filename): Loads an image from a file.
- pygame.image.save(surface, filename): Saves a Surface to an image file.