Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@vickyg3
Created June 23, 2012 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vickyg3/2978964 to your computer and use it in GitHub Desktop.
Save vickyg3/2978964 to your computer and use it in GitHub Desktop.
Temple runner controller
#! /home/vignesh/android-sdk-linux/tools/monkeyrunner
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
import sys
def jump():
global device
device.drag((400,900), (400, 800), 0.25)
def duck():
global device
device.drag((400,800), (400, 900), 0.25)
def right():
global device
device.drag((400,800), (500, 800), 0.25)
def left():
global device
device.drag((500,800), (400, 800), 0.2)
print 'waiting for device'
device = MonkeyRunner.waitForConnection()
print 'device attached'
#dummy = raw_input('press enter to start playing')
fnmap = {'a': left, 's': duck, 'd': right, 'w': jump}
while True:
ch = sys.stdin.read(1)
if ch not in fnmap:
print 'doing nothing'
continue
fnmap[ch]()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment