From 1da32b44f8d5b0ad8724b03874d3075e35df54f4 Mon Sep 17 00:00:00 2001 From: Andrew Kesterson Date: Sat, 14 Jun 2014 15:48:52 -0700 Subject: [PATCH] Making AI able to 'see' the player --- moonlight/js/moonlight-skulk.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/moonlight/js/moonlight-skulk.js b/moonlight/js/moonlight-skulk.js index 90d0178..2914019 100644 --- a/moonlight/js/moonlight-skulk.js +++ b/moonlight/js/moonlight-skulk.js @@ -603,23 +603,22 @@ var AISprite = function(game, x, y, key, frame) { return false; } - var viewrect = null; if ( hasState(this, STATE_FACE_LEFT) ) { - viewrect = new Phaser.Rectangle(this.x, this.y - 32, - this.x - this.view_distance, - this.y + 64); + var viewrect = new Phaser.Rectangle(this.x, this.y - 32, + this.x - this.view_distance, + this.y + 64); } else if ( hasState(this, STATE_FACE_RIGHT) ) { - viewrect = new Phaser.Rectangle(this.x + 32, this.y - 32, - this.x + 32 + this.view_distance, - this.y + 64); + var viewrect = new Phaser.Rectangle(this.x + 32, this.y - 32, + this.x + 32 + this.view_distance, + this.y + 64); } else if ( hasState(this, STATE_FACE_DOWN) ) { - viewrect = new Phaser.Rectangle(this.x - 32, this.y + 32, - this.x + 64, - this.y + 32 + this.view_distance); + var viewrect = new Phaser.Rectangle(this.x - 32, this.y + 32, + this.x + 64, + this.y + 32 + this.view_distance); } else if ( hasState(this, STATE_FACE_UP) ) { - viewrect = new Phaser.Rectangle(this.x - 32, this.y, - this.x + 64, - this.y - this.view_distance); + var viewrect = new Phaser.Rectangle(this.x - 32, this.y, + this.x + 64, + this.y - this.view_distance); } else { return false; }