Search
  • Matt Allen (Closed Forum)

"Fun" Mechanics


To try and create "FUN" Mechanics for my projects the first thing I am going to test out is to create a geotagged area.

The idea of this is that when you walk into an area with the app / site open on your phone it will trigger a piece of music when you get there, not just know you are there just for the sake of you being there.


To do this I have created Geotagged areas,


This is the Java Script for twine:

setup.geoFindMe = function() {

function success(position) {

var latitude = position.coords.latitude;

var longitude = position.coords.longitude;

State.variables.latitude = latitude;

State.variables.longitude = longitude;

$('#status').empty().wiki('<a href="https://www.openstreetmap.org/#map=18/' + latitude + '/' + longitude + '" target="_blank">Latitude: ' + latitude + '°, Longitude: ' + longitude + '°</a>');

}

function error() {

$('#status').empty().wiki('Unable to retrieve your location.');

}


State.variables.latitude = 0;

State.variables.longitude = 0;

if (!navigator.geolocation) {

$('#status').empty().wiki('Geolocation is not supported by your browser.');

} else {

$('#status').empty().wiki('Locating…');

navigator.geolocation.getCurrentPosition(success, error);

}

};



This is the button to find location


Are you there?

<<button "Find my location">>

<<run setup.geoFindMe()>>

<</button>>

<span id="status"></span>



This is the way to use the area / geotag to load a certain page.

<<set $precision = 0.200000>>

<<if Math.abs($latitude is 53.891712)<= $precision>> and Math.abs($longtude is -1.608055) <= $precision>><<goto "3">>


<<else>> NO




<</if>>





5 views