-
Notifications
You must be signed in to change notification settings - Fork 0
/
controls.py
63 lines (42 loc) · 1.14 KB
/
controls.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import pyautogui
import time
from datas import timeToEnergy, lastControl
timeStart = time.time()
def energy():
# take a energy boost to avoid monster for example
if (time.time() - timeStart > timeToEnergy):
print("TURBO !!")
pyautogui.keyDown('down')
pyautogui.keyUp('down')
pyautogui.keyDown('down')
pyautogui.keyUp('down')
lastControl = 'down'
def turnLeft():
# turn left
pyautogui.keyDown('left')
pyautogui.keyUp('left')
lastControl = 'left'
def turnRight():
# turn right
pyautogui.keyDown('right')
pyautogui.keyUp('right')
lastControl = 'right'
def reset():
# go back to the initial position of the surfer
pyautogui.keyDown('down')
pyautogui.keyUp('down')
lastControl = 'down'
def standBy():
# take a pause
pyautogui.keyDown('up')
pyautogui.keyUp('up')
lastControl = 'up'
def restartGame():
# press spacebar to restart game
pyautogui.keyDown('space')
time.sleep(0.5)
pyautogui.keyUp('space')
def control():
# use the last control
pyautogui.keyDown(lastControl)
pyautogui.keyUp(lastControl)