t.chase = function(x, y) {
	///////////////////////////////////////////////////////////////////////
	/*
	var ang = Math.atan2(y - this.y[0], x - this.x[0]);
	var dis = dist(x, y, this.x[0], this.y[0]);
	
	var dx = this.x[0] + Math.cos(ang - d2r(45)) * dis/2;
	var dy = this.y[0] + Math.sin(ang - d2r(45)) * dis/2;
	
	this.x.unshift(dx);
	this.y.unshift(dy);
	
	var dx = this.x[0] + Math.cos(ang + d2r(45)) * dis/2;
	var dy = this.y[0] + Math.sin(ang + d2r(45)) * dis/2;
	
	this.x.unshift(dx);
	this.y.unshift(dy);
	*/
	///////////////////////////////////////////////////////////////////////
	
	var ang = Math.atan2(y - this.y[0], x - this.x[0]);
	var dis = dist(x, y, this.x[0], this.y[0]);
	
	var dx = this.x[0] + Math.cos(ang) * dis/2;
	var dy = this.y[0] + Math.sin(ang) * dis/2;
	
	this.x.unshift(dx);
	this.y.unshift(dy);
	
	this.x.length = this.lim;
	this.y.length = this.lim;
}

t.inside = function(x, y) {
	if (m.c) return false;
	
	var poly = [];
	for (var i = 0; i < this.x.length; i++) {
		poly[i] = [];
		poly[i].x = this.x[i];
		poly[i].y = this.y[i];
	}

	return isPointInPoly(poly, {'x': x, 'y': y});
}

t.draw = function() {
	ctx.beginPath();
	
	ctx.moveTo(this.x[0], this.y[0]);
	for (var i = 1; i < this.x.length; i++) ctx.lineTo(this.x[i], this.y[i]);
	
	if (!m.c) {
		ctx.fillStyle = "rgba(0, 255, 0, 0.3)";
		ctx.fill();
	}
	
	ctx.lineWidth = 3;
	ctx.strokeStyle = "#a0a0a0";
	ctx.stroke();
	
	ctx.closePath();
	
	if (!m.c) {
		ctx.beginPath();
		
		ctx.moveTo(this.x[this.x.length-1], this.y[this.y.length-1]);
		ctx.lineTo(this.x[0], this.y[0]);
		
		ctx.strokeStyle = "rgba(0, 255, 0, 0.2)";
		ctx.stroke();
		
		ctx.closePath();
	}
	
	circle(this.x[0], this.y[0], 5, "rgba(26,28,28,0.5)");
	circle(this.x[0], this.y[0], 10, "rgba(26,28,28,0.1)");
}

t.update = function() {
	this.chase(m.x, m.y);
	this.draw();
}
