Created
June 23, 2012 16:42
-
-
Save vickyg3/2978964 to your computer and use it in GitHub Desktop.
Temple runner controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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