Esempio n. 1
0
	update: function () {
		World.broadphase.update();
		for (var i = 0; i < this.path.length; i++) {
			DebugDraw.point(Kai.debugCtx, this.path[i], null, 'rgb(255, 255, 0)');
			if (this.path[i+1]) {
				DebugDraw.vectorLine(Kai.debugCtx, this.path[i], this.path[i+1], 'rgb(255, 255, 0)');
			}
		}
	},
Esempio n. 2
0
	flock: function flock() {
		if (--this._refreshGroupInterval === 0) {
			// throttle this call because it's *really* expensive, and no one will notice anyway
			World.broadphase.getNeighbors(this.body, this.boid.flockRadius, this._group);
			this._refreshGroupInterval = 3;
		}
		
		Steering.flock(this.boid, this._group);
		
		// DEBUG DRAWING
		var node = this._group.first;
		var t = 100 * this.boid.groupID;
		var color = 'rgb('+t+','+0+','+t+')';
		while (node) {
			var a = node.obj.entity;
			if (a !== this) {
				DebugDraw.vectorLine(Kai.debugCtx, this.position, a.position, color);
			}
			node = node.next;
		}
	},