1

We are developing a live-stream, browser based racing game. Our contenders will start to race from a START point and first contender who check-in in STOP venue will won race.

For example this venue will be our STOP venue : https://foursquare.com/venue/2154697

But there is a problem. For example now i'm 1.3km far away from STOP venue but i can check-in and i can win race :) So i have to calculate distance and if distance is lower than 100meters, contender will win.

How can we do it ?

In shortly, i have to verify, contender is really in this venue.

Eray
  • 7,038
  • 16
  • 70
  • 120
  • What are the inputs, and what values are given? I'm assuming there is a set of GPS coordinates as input per contestant (inputs) and a set of GPS coordinates for the venue. Is this correct? – Brian Webster Jul 17 '11 at 16:24
  • @hamlin, yes i need them but FOurSquare API doesn't provide contender's recently coordinates. – Eray Jul 17 '11 at 16:26
  • Does the FourSquare API provide any inputs at all regarding where the contender is? Also, what device will this software be running on. A cell phone? A server? – Brian Webster Jul 17 '11 at 16:28
  • @hamlin11, cell phones, PDAs. – Eray Jul 17 '11 at 16:29
  • Is it safe to assume that we can obtain GPS coordinates from the devices themselves for the contestant locations? – Brian Webster Jul 17 '11 at 16:36

2 Answers2

2

I would suggest that you not use the check in feature to determine a win for exactly the reasons you mention above. Rather, I would suggest that you pull the winning location from foursquare, and then use a native lookup of the device's lat/long to compare to.

If you are making a browser based game, you can pull GPS info directly in JS in most modern OS's browsers (iOs, Android, Palm, etc). Almost all app frameworks support this now as well. While GPS lookup in the browser is a legitimate spec, there are handy JS warpers that help with cross compatibility like this one [[ http://code.google.com/p/geo-location-javascript/ ]]

So now that you know the 'destination' lat/lon and the true position of the player, you can calculate the delta from the location with some trigonometry. Remember though that the lat and log deltas themselves are not as simple as subtraction, as you are playing on a curved surface. The good news is that this stackOverflow article covers how to do this [[ Calculate distance between 2 GPS coordinates ]]

Community
  • 1
  • 1
Evan
  • 3,191
  • 4
  • 29
  • 25
  • tahnk you Evan ! I will use JS for my project. It's working very well on Opera Mobile. I don't need FourSquare API anymore :) – Eray Jul 19 '11 at 22:47
1

The most reliable way to ensure that the user is at the right location is to place a secret code of some kind at the said location that the user would have to find and type.

Since you appear to be running some kind of game, why not arrange a cheap gift (like chocolate or cake) containing the code?

This of course is doable only if the locations you choose are locations which you control in some way. You could arrange a partnership with a café franchise and use the café locations as stop points.

Give a secret code at the start point, and once arrived at the café, the user can convert his secret code into a pastry, or something like that, and his code is used to generate the end code.

Sylverdrag
  • 8,898
  • 5
  • 37
  • 54