This article will show you an example of how to detect the collision between rectangles and points in pygame. You can use the method pygame.Rect.collidepoint(point) to detect whether a rectangle collides a point in pygame, you can use the method pygame.Rect.colliderect(rectangle) to detect whether a rectangle object collides another rectangle object in pygame.
This article will show you examples of how to move or inflate the pygame rectangle by pressing keys, mouse, or by itself automatically.
This example will tell you how to align a rectangle in the pygame main window screen horizontally or vertically. When you press the different keyboard keys, the rectangle will be aligned to the main window screen’s left, right, top, bottom borders, center horizontally or center vertically.
The python pygame.Rect(top, left, width, height) class is used to create a rectangle object. You can specify the rectangle object’s position (top, left) and size (width, height) when you create it. And the rectangle represented area must be drawn on a pygame surface object. This article will tell you how to use the pygame.Rect object …
The pygame.time module is mainly used to manage time and game frame rate per second(FPS). This article will tell you how to use it with examples.
The pygame.mixer module provides several methods to play, pause, stop sounds. It supports a lot of sounds format files. This article will tell you how to use it to play multiple formats of sounds with examples.
The pygame.font module provides methods for you to display text on the Pygame window screen. This article will tell you how to draw text on a Pygame surface object with examples.
This article will tell you 2 methods to draw pixel units on pygame application windows screen with examples. One method will use the method pygame.draw.Rect(), the other method will use the pygame.PixelArray object.
I create a pygame.PixelArray object uses the pygame main screen window surface object ( returned by the method pygame.display.set_mode() ), and when I assign color to each item of the pygame.PixelArray object in a loop it throws the error pygame.PixelArray IndexError: invalid index. This article will tell you how to fix it.
This example will tell you how to implement animation in pygame game application. It will also tell you how to set the game app’s background image, and how to control the animation speed.