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

more tweaks

parent 23c4174d
......@@ -3,7 +3,7 @@ defmodule Grains.Mixfile do
def project do
[app: :grains,
version: "0.0.68",
version: "0.0.69",
elixir: "~> 1.2",
elixirc_paths: elixirc_paths(Mix.env),
compilers: [:phoenix, :gettext] ++ Mix.compilers,
......
......@@ -20,7 +20,7 @@ function Boid(p, x, y, type) {
this.maxspeed = 3; // Maximum speed
this.maxforce = 0.05; // Maximum steering force
this.type = type;
this.separation_f = 2.5;
this.separation_f = 2.0;
this.alignment_f = 1.0;
this.cohesion_f = 2.0;
this.spin = parseInt(this.p.random(-50, 50));
......@@ -111,11 +111,10 @@ Boid.prototype.render = function() {
// Wraparound
Boid.prototype.borders = function() {
let jitter = this.p.random(0.9, 1.1);
if (this.position.x < -this.r) this.velocity.x = -this.velocity.x * jitter;
if (this.position.y < -this.r) this.velocity.y = -this.velocity.y * jitter;
if (this.position.x > PresenceSketch.width + this.r) this.velocity.x = -this.velocity.x * jitter;
if (this.position.y > PresenceSketch.height + this.r) this.velocity.y = -this.velocity.y * jitter;
if (this.position.x < -this.radius) this.velocity.x = -this.velocity.x;
if (this.position.y < -this.radius) this.velocity.y = -this.velocity.y;
if (this.position.x > PresenceSketch.width + this.radius) this.velocity.x = -this.velocity.x;
if (this.position.y > PresenceSketch.height + this.radius) this.velocity.y = -this.velocity.y;
};
// Separation
......@@ -188,7 +187,7 @@ Boid.prototype.align = function(boids) {
// For the average location (i.e. center) of all nearby boids, calculate steering vector towards that location
Boid.prototype.cohesion = function(boids) {
let that = this;
var neighbordist = 150;
var neighbordist = 250;
var sum = this.p.createVector(0, 0); // Start with empty vector to accumulate all locations
var count = 0;
_.each(boids, function(boid) {
......@@ -266,7 +265,7 @@ function Master(p, x, y, type) {
this.master = true;
this.radius = 48;
this.type = type;
this.cohesion_f = 6;
this.cohesion_f = 2;
this.separation_f = 1;
this.alignment_f = 2;
......
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