I have to do a game in 2d using pygame and I don't know how to detect collisions with images
I have tested the collisions with rectangles and it works, but when I try to collide a rectangle with an image, the application crash
import pygame,sys
from pygame.locals import *
from random import randint
pygame.init()
ventana=pygame.display.set_mode((1200,600))
pygame.display.set_caption("Jueguiño")
imageVida= pygame.image.load("vida.jpg")
posX= randint(0,1200)
posY= randint(0,0)
rectangulo=pygame.Rect(0,0,100,50)
velocidad=0.5
Blanco=(255,255,255)
while True:
ventana.fill(Blanco)
ventana.blit(imageVida,(posX,posY))
pygame.draw.rect(ventana,(180,70,70),rectangulo)
rectangulo.left,rectangulo.top=pygame.mouse.get_pos()
if rectangulo.colliderect(imageVida):
velocidad=0
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if posY<1200:
posY+=velocidad
pygame.display.update()