Commit d28cd4ec authored by Jens-Christian Fischer's avatar Jens-Christian Fischer
Browse files

Draw lines on boids that influence their master

parent 752c6d24
......@@ -3,7 +3,7 @@ defmodule Grains.Mixfile do
def project do
[app: :grains,
version: "0.0.70",
version: "0.0.71",
elixir: "~> 1.2",
elixirc_paths: elixirc_paths(Mix.env),
compilers: [:phoenix, :gettext] ++ Mix.compilers,
......
......@@ -279,10 +279,10 @@ Master.prototype.run = function(boids) {
let list = _.filter(boids, function(boid) { return that.type == boid.type; });
this.flock(boids);
this.flock(list);
this.update();
this.borders();
this.render();
this.render(list);
this.send_osc();
}
......@@ -326,7 +326,7 @@ Boid.prototype.fillColor = function() {
return color;
}
Boid.prototype.render = function() {
Boid.prototype.render = function(list) {
this.p.fill(this.color);
this.p.stroke(200);
......@@ -348,8 +348,19 @@ Boid.prototype.render = function() {
this.p.pop();
this.adjust_radius();
// the master looks at his minions and draws lines
if (list) {
let neighbordist = 250;
_.each(list, function(boid) {
var d = p5.Vector.dist(that.position, boid.position);
if ((d > 0) && (d < neighbordist)) {
this.p.stroke(255);
this.p.line(this.position.x, this.position.y,
boid.position.x, boid.position.y);
}
});
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment