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
1d9fa980
Commit
1d9fa980
authored
May 17, 2017
by
Jens-Christian Fischer
Browse files
more tweaks
parent
23c4174d
Changes
2
Hide whitespace changes
Inline
Side-by-side
mix.exs
View file @
1d9fa980
...
...
@@ -3,7 +3,7 @@ defmodule Grains.Mixfile do
def
project
do
[
app:
:grains
,
version:
"0.0.6
8
"
,
version:
"0.0.6
9
"
,
elixir:
"~> 1.2"
,
elixirc_paths:
elixirc_paths
(
Mix
.
env
),
compilers:
[
:phoenix
,
:gettext
]
++
Mix
.
compilers
,
...
...
web/static/js/presencesketch.js
View file @
1d9fa980
...
...
@@ -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
=
1
50
;
var
neighbordist
=
2
50
;
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
;
...
...
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