Making AI able to 'see' the player
This commit is contained in:
@@ -590,26 +590,26 @@ EffectSprite.prototype.constructor = EffectSprite;
|
|||||||
var AISprite = function(game, x, y, key, frame) {
|
var AISprite = function(game, x, y, key, frame) {
|
||||||
this.viewRectangle = function() {
|
this.viewRectangle = function() {
|
||||||
if ( hasState(this, STATE_FACE_LEFT) ) {
|
if ( hasState(this, STATE_FACE_LEFT) ) {
|
||||||
var viewrect = new Phaser.Rectangle(this.x, this.y - 32,
|
return new Phaser.Rectangle(this.x, this.y - 32,
|
||||||
this.x - this.view_distance,
|
this.x - this.view_distance,
|
||||||
this.y + 64);
|
this.y + 64);
|
||||||
} else if ( hasState(this, STATE_FACE_RIGHT) ) {
|
} else if ( hasState(this, STATE_FACE_RIGHT) ) {
|
||||||
var viewrect = new Phaser.Rectangle(this.x + 32, this.y - 32,
|
return new Phaser.Rectangle(this.x + 32, this.y - 32,
|
||||||
this.x + 32 + this.view_distance,
|
this.x + 32 + this.view_distance,
|
||||||
this.y + 64);
|
this.y + 64);
|
||||||
} else if ( hasState(this, STATE_FACE_DOWN) ) {
|
} else if ( hasState(this, STATE_FACE_DOWN) ) {
|
||||||
var viewrect = new Phaser.Rectangle(this.x - 32, this.y + 32,
|
return new Phaser.Rectangle(this.x - 32, this.y + 32,
|
||||||
this.x + 64,
|
this.x + 64,
|
||||||
this.y + 32 + this.view_distance);
|
this.y + 32 + this.view_distance);
|
||||||
} else if ( hasState(this, STATE_FACE_UP) ) {
|
} else if ( hasState(this, STATE_FACE_UP) ) {
|
||||||
var viewrect = new Phaser.Rectangle(this.x - 32, this.y,
|
return new Phaser.Rectangle(this.x - 32, this.y,
|
||||||
this.x + 64,
|
this.x + 64,
|
||||||
this.y - this.view_distance);
|
this.y - this.view_distance);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.canSeeSprite = function(spr, debug) {
|
this.canSeeSprite = function(spr, debug) {
|
||||||
var xd = (spr.x - this.x);
|
var xd = (spr.x - this.x);
|
||||||
if ( xd < 0 )
|
if ( xd < 0 )
|
||||||
|
|||||||
Reference in New Issue
Block a user