Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import console, location
- from scene import *
- running = True
- testaddr = {'Street': 'Infinite Loop', 'City': 'Cupertino', 'Country': 'USA'}
- testcoords = (())
- def geocode():
- testcoords = location.geocode(testaddr)
- class MainScene (Scene):
- def __init__(self):
- self.btn = 0
- def setup(self):
- # This will be called before the first frame is drawn.
- pass
- def draw(self):
- # This will be called for every frame (typically 60 times per second).
- background(0, 0, 0)
- # draw wannabe buttons
- fill(0, 0, 1)
- rect(0, 0, 200, 200)
- fill(0, 1, 0)
- rect(0, 200, 200, 200)
- fill(1, 1, 0)
- rect(0, 400, 200, 200)
- # Draw a red circle for every finger that touches the screen:
- fill(1, 0, 0)
- for touch in self.touches.values():
- ellipse(touch.location.x - 50, touch.location.y - 50, 100, 100)
- def touch_began(self, touch):
- # determines touched "button"
- if touch.location.x < 200:
- if touch.location.y < 200:
- self.btn = 1
- elif touch.location.y < 400:
- self.btn = 2
- elif touch.location.y < 600:
- self.btn = 3
- def touch_moved(self, touch):
- pass
- def touch_ended(self, touch):
- # runs the tapped button's corresponding function
- if self.btn == 1:
- self.dumploc()
- elif self.btn == 2:
- self.dumpaddr()
- elif self.btn == 3:
- self.geocode()
- self.btn = 0
- def dumploc(self):
- location.start_updates()
- self.loc = location.get_location()
- print(self.loc)
- location.stop_updates()
- def dumpaddr(self):
- self.addr = location.reverse_geocode(self.loc)
- print(self.addr)
- def geocode(self):
- geocode()
- print(testcoords)
- run(MainScene())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement