Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from threading import Timer
- WalkingAccelThreshold = 4
- KeyDelaySeconds = 0.1
- def update():
- global accel
- global maxaccel
- accel = math.sqrt(math.fabs(math.pow(android[0].raw.ax, 2) + math.pow(android[0].raw.ay, 2) + math.pow(android[0].raw.az, 2) - math.pow(9.8, 2)))
- maxaccel = max(accel, maxaccel)
- def timertick():
- global maxaccel
- if isexecuting:
- global timer
- timer = Timer(KeyDelaySeconds, timertick)
- timer.start()
- if maxaccel >= WalkingAccelThreshold:
- keyboard.setPressed(Key.W)
- maxaccel = 0
- if starting:
- android[0].update += update
- accel = 0
- maxaccel = 0
- isexecuting = True
- timertick()
- if stopping:
- if timer:
- timer.cancel()
- isexecuting = False
Advertisement
Add Comment
Please, Sign In to add comment