From b76fe63520a011550a84cda724d3cf3f23a60065 Mon Sep 17 00:00:00 2001 From: Andrew Kesterson Date: Sat, 14 Jun 2014 19:27:31 -0700 Subject: [PATCH] Light meter --- moonlight/js/moonlight-skulk.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/moonlight/js/moonlight-skulk.js b/moonlight/js/moonlight-skulk.js index a9ee9ac..71e0a32 100644 --- a/moonlight/js/moonlight-skulk.js +++ b/moonlight/js/moonlight-skulk.js @@ -1099,15 +1099,20 @@ GameState.prototype.check_input = function() GameState.prototype.update = function() { this.check_input(); - this.shadowTexture.update(player.x-1, player.y-1, 34, 34); - lightcheck = [ - this.shadowTexture.getPixelRGB(player.x, player.y), - this.shadowTexture.getPixelRGB(player.x + 32, player.y), - this.shadowTexture.getPixelRGB(player.x + 32, player.y + 32), - this.shadowTexture.getPixelRGB(player.x, player.y + 32) - ]; - - console.log(lightcheck); + lightness = 0; + this.shadowTexture.processPixelRGB( + function(x) { + var val = (x['r'] + x['g'] + x['b']) / 3; + if ( val > lightness ) + lightness = val; + }, + this, + player.x, + player.y, + 32, + 32); + + console.log(lightness); for (var ln in this.map_collision_layers ) { layer = this.map_collision_layers[ln];