Game Development with Python and Pygame

  1. Handling User Input and Events
    1. The Pygame Event System
      1. The Event Queue
        1. How Events are Queued
          1. Event Queue Limitations
            1. Event Queue Management
            2. The pygame.event.get() Loop
              1. Iterating Over Events
                1. Filtering Events
                  1. Event Queue Clearing
                  2. The pygame.Event Object
                    1. Event Attributes
                      1. Creating Custom Events
                    2. Common Event Types
                      1. QUIT
                        1. Handling Window Close Events
                        2. KEYDOWN and KEYUP
                          1. Detecting Key Presses and Releases
                            1. Key Repeat Events
                            2. MOUSEBUTTONDOWN and MOUSEBUTTONUP
                              1. Detecting Mouse Button Actions
                                1. Mouse Button Types
                                2. MOUSEMOTION
                                  1. Tracking Mouse Movement
                                    1. Mouse Position and Relative Movement
                                    2. Custom User Events
                                      1. Defining Custom Event Types
                                        1. Posting Custom Events to the Queue
                                      2. Keyboard Input
                                        1. Reading Key Presses from the Event Queue
                                          1. Accessing Key Codes
                                            1. Handling Modifier Keys
                                              1. Unicode Key Input
                                              2. Checking for Held-Down Keys
                                                1. Using pygame.key.get_pressed()
                                                  1. Continuous Movement with Held Keys
                                                  2. Key Mapping and Configuration
                                                    1. Creating Key Bindings
                                                      1. Customizable Controls
                                                    2. Mouse Input
                                                      1. Getting Mouse Position
                                                        1. Retrieving Cursor Coordinates
                                                          1. Screen vs. Game Coordinates
                                                          2. Getting Mouse Button States
                                                            1. Checking Button States
                                                              1. Handling Multiple Buttons
                                                              2. Mouse Cursor Management
                                                                1. Hiding and Showing Cursor
                                                                  1. Custom Cursor Images
                                                                2. Joystick and Gamepad Input
                                                                  1. Initializing Joystick Support
                                                                    1. Detecting Connected Joysticks
                                                                      1. Reading Joystick Input
                                                                        1. Button Presses
                                                                          1. Analog Stick Values
                                                                            1. Trigger Values