Created
July 23, 2016 01:31
-
-
Save scturtle/c319680b63bae2234eddbd5645c58ecb to your computer and use it in GitHub Desktop.
Go! Pokemon go!
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
import os | |
import bottle | |
ip = '233.233.233.233' | |
x = 51.505494 | |
y = -0.12369 | |
add = 0.0001 | |
p1 = (55, 770) | |
p2 = (55, 820) | |
@bottle.get('/') | |
def index(): | |
return '''\ | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Control</title> | |
<style> | |
.btn {height: 100px; width: 100px; border: 1px solid;} | |
.l {margin-left: 50px;} | |
.r {display: inline; padding: 50px;} | |
.c {margin: 50px 0;} | |
</style> | |
<script> | |
function p(c){ | |
xmlhttp = new XMLHttpRequest(); | |
xmlhttp.open("POST","http://%s:8080/move/"+c,true); | |
xmlhttp.send(); | |
} | |
</script> | |
</head> | |
<body> | |
<div class="btn l" onclick="p('w')"></div> | |
<div class="c"> | |
<div class="btn r" onclick="p('a')"></div> | |
<div class="btn r" onclick="p('d')"></div> | |
</div> | |
<div class="btn l" onclick="p('s')"></div> | |
</body> | |
</html>''' % ip | |
@bottle.post('/move/<ch>') | |
def move(ch): | |
global x, y, add | |
if ch == 'a': | |
y -= add | |
elif ch == 's': | |
x -= add | |
elif ch == 'd': | |
y += add | |
elif ch == 'w': | |
x += add | |
print("({:.6f},{:.6f})".format(x, y)) | |
with open('PATH_TO/point.gpx', 'w') as f: | |
f.write('''\ | |
<?xml version="1.0" encoding="UTF-8" standalone="no" ?> | |
<gpx> | |
<wpt lat="{:.6f}" lon="{:.6f}"> | |
<name>here</name> | |
<time>2016-07-21T21:32:51Z</time> | |
</wpt> | |
</gpx>'''.format(x, y)) | |
# http://stackoverflow.com/a/26687223/2785942 | |
os.system("./click -x {} -y {}".format(*p1)) | |
os.system("./click -x {} -y {}".format(*p2)) | |
bottle.run(host='0.0.0.0', port=8080, quiet=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment