Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
🚀
This server has been upgraded to GitLab release
15.7
.
🚀
Open sidebar
grains
grains-web
Commits
23c4174d
Commit
23c4174d
authored
May 17, 2017
by
Jens-Christian Fischer
Browse files
Tweak flocking
parent
f7247b57
Changes
2
Hide whitespace changes
Inline
Side-by-side
mix.exs
View file @
23c4174d
...
...
@@ -3,7 +3,7 @@ defmodule Grains.Mixfile do
def
project
do
[
app:
:grains
,
version:
"0.0.6
7
"
,
version:
"0.0.6
8
"
,
elixir:
"~> 1.2"
,
elixirc_paths:
elixirc_paths
(
Mix
.
env
),
compilers:
[
:phoenix
,
:gettext
]
++
Mix
.
compilers
,
...
...
web/static/js/presencesketch.js
View file @
23c4174d
...
...
@@ -68,7 +68,7 @@ Boid.prototype.flock = function(boids) {
coh
.
mult
(
this
.
cohesion_f
);
// Add the force vectors to acceleration
this
.
applyForce
(
sep
);
this
.
applyForce
(
ali
);
//
this.applyForce(ali);
this
.
applyForce
(
coh
);
};
...
...
@@ -122,7 +122,7 @@ Boid.prototype.borders = function() {
// Method checks for nearby boids and steers away
Boid
.
prototype
.
separate
=
function
(
boids
)
{
let
that
=
this
;
var
desiredseparation
=
2
5.0
;
var
desiredseparation
=
5
0
.0
;
var
steer
=
this
.
p
.
createVector
(
0
,
0
);
var
count
=
0
;
// For every boid in the system, check if it's too close
...
...
@@ -188,7 +188,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
=
50
;
var
neighbordist
=
1
50
;
var
sum
=
this
.
p
.
createVector
(
0
,
0
);
// Start with empty vector to accumulate all locations
var
count
=
0
;
_
.
each
(
boids
,
function
(
boid
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment