52 lines
1.4 KiB
Python
52 lines
1.4 KiB
Python
|
import keyboard
|
||
|
import mouse
|
||
|
|
||
|
|
||
|
class HumanActions:
|
||
|
def __init__(self, mouseDiscount: float = 10, screenW: int = 1920, screenH: int = 1080):
|
||
|
def multiPressed():
|
||
|
pass
|
||
|
|
||
|
keyboard.add_hotkey("w+a", multiPressed)
|
||
|
keyboard.add_hotkey("w+d", multiPressed)
|
||
|
keyboard.add_hotkey("s+a", multiPressed)
|
||
|
keyboard.add_hotkey("s+d", multiPressed)
|
||
|
self.screenW = screenW
|
||
|
self.screenH = screenH
|
||
|
self.MOUSEDISCOUNT = mouseDiscount
|
||
|
|
||
|
def getHumanActions(self):
|
||
|
x, _ = mouse.get_position()
|
||
|
xMovement = (x - self.screenW / 2) / self.MOUSEDISCOUNT
|
||
|
|
||
|
ws = 0
|
||
|
ad = 0
|
||
|
click = 0
|
||
|
if keyboard.is_pressed("w"):
|
||
|
ws = 1
|
||
|
elif keyboard.is_pressed("s"):
|
||
|
ws = 2
|
||
|
if keyboard.is_pressed("d"):
|
||
|
ad = 1
|
||
|
elif keyboard.is_pressed("a"):
|
||
|
ad = 2
|
||
|
if keyboard.is_pressed("w+d"):
|
||
|
ws = 1
|
||
|
ad = 1
|
||
|
elif keyboard.is_pressed("w+a"):
|
||
|
ws = 1
|
||
|
ad = 2
|
||
|
elif keyboard.is_pressed("s+d"):
|
||
|
ws = 2
|
||
|
ad = 1
|
||
|
elif keyboard.is_pressed("s+a"):
|
||
|
ws = 2
|
||
|
ad = 2
|
||
|
if mouse.is_pressed(button="left"):
|
||
|
click = 1
|
||
|
|
||
|
actions = [ws, ad, click, [xMovement]]
|
||
|
|
||
|
mouse.move(self.screenW / 2, self.screenH / 2)
|
||
|
return actions
|