Merge branch 'LLK/master'

Replace my timeAndDate code with Shane's.
This commit is contained in:
Scimonster 2013-10-30 21:01:42 +02:00
commit dcd0a43348
2 changed files with 21 additions and 5 deletions

View file

@ -177,6 +177,22 @@ Runtime.prototype.spriteNamed = function(n) {
});
return selected_sprite;
}
Runtime.prototype.getTimeString = function(which) {
// Return local time properties.
var now = new Date();
switch (which) {
case 'hour': return now.getHours();
case 'minute': return now.getMinutes();
case 'second': return now.getSeconds();
case 'year': return now.getFullYear(); // four digit year (e.g. 2012)
case 'month': return now.getMonth() + 1; // 1-12
case 'date': return now.getDate(); // 1-31
case 'day of week': return now.getDay() + 1; // 1-7, where 1 is Sunday
}
return ''; // shouldn't happen
}
// Reassigns z-indices for layer functions
Runtime.prototype.reassignZ = function(target, move) {

View file

@ -30,7 +30,7 @@ SensingPrims.prototype.addPrimsTo = function(primTable) {
primTable['getAttribute:of:'] = this.primGetAttribute;
primTable['timeAndDate'] = this.primTimeDate;
primTable['timeAndDate'] = function(b){ return runtime.getTimeString(interp.arg(b, 0)); };
primTable['timestamp'] = this.primTimestamp;
}
@ -127,9 +127,9 @@ var stageColorHitTest = function(target, color) {
var stageColorByColorHitTest = function(target, myColor, otherColor) {
var threshold_acceptable = function(a, b, c, x, y, z) {
diff_a = Math.abs(a-x);
diff_b = Math.abs(b-y);
diff_c = Math.abs(c-z);
var diff_a = Math.abs(a-x);
var diff_b = Math.abs(b-y);
var diff_c = Math.abs(c-z);
if (diff_a + diff_b + diff_c < 100) {
return true;
}
@ -157,7 +157,7 @@ var stageColorByColorHitTest = function(target, myColor, otherColor) {
var hitCanvas = document.createElement('canvas');
hitCanvas.width = 480;
hitCanvas.height = 360;
hitCtx = hitCanvas.getContext('2d');
var hitCtx = hitCanvas.getContext('2d');
$.each(runtime.sprites, function(i, sprite) {
if (sprite != target)
sprite.stamp(hitCtx, 100);