“Pos de souris pygame” Réponses codées

Pygame obtient une position de souris

x,y = pygame.mouse.get_pos()
#get the mouse cursor position
#get_pos() -> (x, y)
#Returns the X and Y position of the mouse cursor.
#The position is relative to the top-left corner of the display.
#The cursor position can be located outside of the display window,
#but is always constrained to the screen.
8Dion8

souris en pygame

pygame.mouse.get_pos() #-> get the mouse cursor position on the screen in taple
#-> (x, y)

if event.type == pygame.MOUSEBUTTONDOWN:
    print(event.button)

#------------------------#
1 - left click
2 - middle click
3 - right click
4 - scroll up
5 - scroll down
#------------------------#
Shakedcode

Pos de souris pygame

 pygame.mouse.get_pos()
    get the mouse cursor position
    get_pos() -> (x, y)

    Returns the x and y position of the mouse cursor. 
    The position is relative to the top-left corner of the display. 
    The cursor position can be located outside of the display window,
    but is always constrained to the screen.
Bad Bat

point pygame à la souris

import math

def rotate(self):
    mouse_x, mouse_y = pygame.mouse.get_pos()
    rel_x, rel_y = mouse_x - self.x, mouse_y - self.y
    angle = (180 / math.pi) * -math.atan2(rel_y, rel_x)
    self.image = pygame.transform.rotate(self.original_image, int(angle))
    self.rect = self.image.get_rect(center=self.position)
Alive Ant

Réponses similaires à “Pos de souris pygame”

Questions similaires à “Pos de souris pygame”

Plus de réponses similaires à “Pos de souris pygame” dans Python

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code