## 2014년 12월 10일 수요일

### GPS Scavenger Hunt

I've just gotten into App inventor and I'm excited by the possibilities!

I have what I assume is a beginner question. I'm trying to make a scavenger hunt app that uses GPS to determine if the player has reached one of a list of predetermined locations (they have to find these locations based on clues). I'm unsure on the basic coding here. I was thinking I wanted something like "When LocationSenseor1.LocationChanged"+"If [location]"+"is in list, then"... etc.

But I can't find a block along the lines of "if location = x" I'm not sure what I need to do here. I'm guessing I need to create a variable for Latitude, Longitude and Altitude then compare that to a list of the coordinates of the target spots?

Also, I'd really like it if there could be a "you're getting close" sort of message if the user got close to a target (say, within 50 feet). How could I do that?

--
First, you might build your confidence in programming AI2 with the following:

AI2 free online eBook   http://appinventor.mit.edu/explore/ai2/tutorials.html   ... the links are at the bottom of the Web page.  This is a free course in how to program with AI2.

In the MIT tutorials is the LocationSensor tutorial.   It explains one way of determining how close you are to a location..actually it tells you if you are within the distance specified and it is an excellent method.  This is your "getting close" scenario.

Within the book
is a short discussion of using the LocationSensor.

Also within the book
is an overly simplified algorithm to calculate straight line distance between points, I would never use because it is VERY inaccurate. Search the Internet for an algorithm called   Haversine      and get a much better distance estimate with about as much coding effort.

In chapter http://www.appinventor.org/bookChapters/chapter18.pdf   there is a discussion of using boundaries to determine whether one is with a area on a map... which is pretty good;   Programming Complex Conditions is your  "if location = x"

Do some reading, try some blocks and you can build it.

--
Thanks Steve!

--