Pygame Functions - Poppadomus/pygameTDS GitHub Wiki

Core Pygame Functions: pygame.init() pygame.quit() pygame.display.set_mode() pygame.display.set_caption() pygame.display.flip() pygame.time.get_ticks() pygame.time.set_timer()

Pygame Classes and Objects: pygame.sprite.Sprite pygame.sprite.Group() pygame.Surface pygame.Rect pygame.mask.from_surface() pygame.font.Font() pygame.transform.rotate() pygame.transform.scale()

**Pygame Event Handling: **pygame.event.get() pygame.QUIT pygame.KEYDOWN pygame.MOUSEBUTTONDOWN pygame.MOUSEMOTION pygame.MOUSEWHEEL pygame.mouse.get_pressed() pygame.mouse.get_pos() pygame.mouse.set_visible()

**Pygame Drawing Functions: **pygame.draw.rect() pygame.draw.circle() screen.blit() surface.fill() Pygame Sound: pygame.mixer.init() pygame.mixer.Sound() pygame.mixer.Sound.play()

Pygame Math: pygame.math.Vector2

Pygame Clock: pygame.time.Clock() clock.tick() clock.get_fps()

Pygame Image Loading: pygame.image.load().convert_alpha() pygame.image.load().convert()

How they are used:

pygame.init() Initializes all Pygame modules

pygame.quit() Shuts down Pygame properly

pygame.display.set_mode() Creates the game window with specified dimensions

pygame.display.set_caption() Sets the window title

pygame.display.flip() Updates the entire display

pygame.time.get_ticks() Gets current time in milliseconds

pygame.time.set_timer() Creates a timer event

pygame.sprite.Sprite Base class for game objects

pygame.sprite.Group() Container to hold and manage multiple sprites

pygame.Surface Object for representing images

pygame.Rect Rectangle object for positions and collisions

pygame.mask.from_surface() Creates collision mask from surface

pygame.font.Font() Creates font object for text rendering

pygame.transform.rotate() Rotates surfaces

pygame.transform.scale() Resizes surfaces

pygame.event.get() Gets all pending events

pygame.QUIT Event type when window is closed

pygame.KEYDOWN Event type when key is pressed

pygame.MOUSEBUTTONDOWN Event type when mouse button is clicked

pygame.MOUSEMOTION Event type when mouse moves

pygame.MOUSEWHEEL Event type when mouse wheel scrolls

pygame.mouse.get_pressed() Gets state of mouse buttons

pygame.mouse.get_pos() Gets current mouse position

pygame.mouse.set_visible() Shows/hides mouse cursor

pygame.draw.rect() Draws rectangle shape

pygame.draw.circle() Draws circle shape

screen.blit() Draws one surface onto another

surface.fill() Fills surface with color

pygame.mixer.init() Initializes sound system

pygame.mixer.Sound() Creates sound object

pygame.mixer.Sound.play() Plays a sound

pygame.math.Vector2 2D vector for calculations

pygame.time.Clock() Creates time tracking object

clock.tick() Controls game speed/framerate

clock.get_fps() Gets current frames per second

pygame.image.load().convert_alpha() Loads image with transparency

pygame.image.load().convert() Loads image optimized for display