summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCode WvS <code-wvs@quantentunnel.de>2015-03-22 18:04:10 +0100
committerCode WvS <code-wvs@quantentunnel.de>2015-03-22 18:04:10 +0100
commit8cbb9efd39b0c21c1a7237cee39b52d3dba587f4 (patch)
tree257537417b08ce9455cf07555f8254f800b6a1b2
parente05bec7d42f3a85f50f4863cc7d74c2e40edd3c0 (diff)
downloadsnap-yow-8cbb9efd39b0c21c1a7237cee39b52d3dba587f4.tar.gz
snap-yow-8cbb9efd39b0c21c1a7237cee39b52d3dba587f4.zip
add distanceFromTo block
-rw-r--r--objects.js6
-rw-r--r--threads.js6
2 files changed, 12 insertions, 0 deletions
diff --git a/objects.js b/objects.js
index e76992b..f757ea4 100644
--- a/objects.js
+++ b/objects.js
@@ -881,6 +881,11 @@ SpriteMorph.prototype.initBlocks = function () {
category: 'sensing',
spec: 'distance to %dst'
},
+ reportDistanceFromTo: {
+ type: 'reporter',
+ category: 'sensing',
+ spec: 'distance from longitude: %n latitude: %n to lon: %n lat: %n'
+ },
doResetTimer: {
type: 'command',
category: 'sensing',
@@ -2038,6 +2043,7 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push(block('reportKeyPressed'));
blocks.push('-');
blocks.push(block('reportDistanceTo'));
+ blocks.push(block('reportDistanceFromTo'));
blocks.push('-');
blocks.push(block('doResetTimer'));
blocks.push(watcherToggle('getTimer'));
diff --git a/threads.js b/threads.js
index 519922c..2817144 100644
--- a/threads.js
+++ b/threads.js
@@ -2509,6 +2509,12 @@ Process.prototype.reportDistanceTo = function (name) {
return 0;
};
+Process.prototype.reportDistanceFromTo = function (lon1, lat1, lon2, lat2) {
+ var thisPoint = L.latLng(lat1, lon1),
+ thatPoint = L.latLng(lat2, lon2);
+ return thisPoint.distanceTo(thatPoint);
+};
+
Process.prototype.reportAttributeOf = function (attribute, name) {
var thisObj = this.blockReceiver(),
thatObj,