Skip to main content
fixed typos, added code markdown
Source Link
Pikalek
  • 13.4k
  • 5
  • 49
  • 54

iI just ran into this issue when creating a board using triangles, iI simply wanted to highlight whichever triangle the mouse was hovering over. asAs such iI figured out:

whenWhen drawing the polygons you can simultaneously use the collidepoint()collidepoint() function to get a bool from the mouse position.

e.g.

if pg.draw.polygon(screen, white, polygon, 1).collidepoint(pg.mouse.get_pos()):
    pg.draw.polygon(screen, white, polygon, 0)

i just ran into this issue when creating a board using triangles, i simply wanted to highlight whichever triangle the mouse was hovering over. as such i figured out:

when drawing the polygons you can simultaneously use the collidepoint() function to get a bool from the mouse position.

e.g.

if pg.draw.polygon(screen, white, polygon, 1).collidepoint(pg.mouse.get_pos()):
    pg.draw.polygon(screen, white, polygon, 0)

I just ran into this issue when creating a board using triangles, I simply wanted to highlight whichever triangle the mouse was hovering over. As such I figured out:

When drawing the polygons you can simultaneously use the collidepoint() function to get a bool from the mouse position.

e.g.

if pg.draw.polygon(screen, white, polygon, 1).collidepoint(pg.mouse.get_pos()):
    pg.draw.polygon(screen, white, polygon, 0)
Source Link

i just ran into this issue when creating a board using triangles, i simply wanted to highlight whichever triangle the mouse was hovering over. as such i figured out:

when drawing the polygons you can simultaneously use the collidepoint() function to get a bool from the mouse position.

e.g.

if pg.draw.polygon(screen, white, polygon, 1).collidepoint(pg.mouse.get_pos()):
    pg.draw.polygon(screen, white, polygon, 0)