xxxxxxxxxx
## Checks if the mouse cursor is colliding with a white rectangle:
import pygame as pg
import sys
pg.init()
screen = pg.display.set_mode((800,600))
while 1:
for event in pg.event.get():
if event.type == pg.QUIT:
pg.quit()
sys.exit()
screen.fill('black')
mouse_pos = pg.mouse.get_pos() ## gets (x,y) position of mouse cursor
rect = pg.Rect(0,0, 100,100)
pg.draw.rect(screen, 'white', rect)
if rect.collidepoint(mouse_pos): print("Collision")
else: print("Not Collision")
pg.display.update()
pg.quit()