I'm a beginner in Pygame and I'm having trouble trying to blit an image onto specific rects.
obstacle_width = 70
obstacle_height = random.randint(150, 450)
obstacle_colour = (211, 253, 117)
obstacle_x_change = -4
obstacle_x = 500
obstacle_gap = 170
def display_obstacle(height):
top = pygame.draw.rect(screen, obstacle_colour,
(obstacle_x, 0, obstacle_width, height))
bottom_obstacle_height = 635 - height - obstacle_gap
bottom = pygame.draw.rect(screen, obstacle_colour,
(obstacle_x, height + obstacle_gap, obstacle_width,
bottom_obstacle_height))
I want to blit an image inside both the top
and the bottom
rects. I know how to add an image onto Pygame, but I want the image to be inside the rects, instead of above/below them.
Any help would be greatly appreciated!