Answers for "how to make a object follow the mouse python pygame"

3

mouse in 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
#------------------------#
Posted by: Guest on July-28-2021
0

move the mouse in games python

# Import modules
import win32api, win32con

# Set target position
tx, ty = 0, 0

# Mouse move event
win32api.mouse_event(win32con.MOUSEEVENTF_MOVE | win32con.MOUSEEVENTF_ABSOLUTE, int(tx/win32api.GetSystemMetrics(0)*65535), int(ty/win32api.GetSystemMetrics(1)*65535) ,0 ,0)
Posted by: Guest on August-08-2021

Code answers related to "how to make a object follow the mouse python pygame"

Python Answers by Framework

Browse Popular Code Answers by Language