Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python pygame how to check if the mouse is on a rect

rect = pygame.Rect(x,y,width,height)
mouse = pygame.mouse.get_pos()

mouse_on_rect = rect.collidepoint(mouse)
# this will tell you if the mouse(a 1x1 rect) is on the rect variable)
 
PREVIOUS NEXT
Tagged: #python #pygame #check #mouse #rect
ADD COMMENT
Topic
Name
4+4 =