[Python] How can I get the position of the mouse cursor in pygame? [duplicate]

Discussão em 'Python' iniciado por Stack, Maio 20, 2025.

  1. Stack

    Stack Membro Participativo

    I would like to program a game in which i can draw in a surface using pygame. The problem is that i have no idea how to manage to change the color of a pixel when the cursor is over it because I don't know how to get the cursor's coordonates which are needed for the function I am using ( pygame.gfxdraw.pixel(surface,x,y,color) ).

    I tried multiples different programs but none worked. I managed to do one in which everytime you click a pixel changes color but I have to specify the coordonates before.

    Continue reading...

Compartilhe esta Página