Skip to content
This repository has been archived by the owner on Mar 3, 2024. It is now read-only.

Commit

Permalink
probably should explain that random() call...
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrosso committed May 1, 2012
1 parent 7bb8b4e commit 7cbbff5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/assets/javascripts/flocks.js.coffee
Expand Up @@ -281,6 +281,11 @@ class @Flock
if @debug then console.log 'change_len',change_len, @maxa, x, y, vxprev, vyprev
if( change_len > @maxa )
shrink = @maxa / change_len
################################################
# some random juice is needed to avoid 2 cycles
# where birds are bounce away and back towards
# each other
################################################
newx = ( x - vxprev ) * shrink + Math.random()
newy = ( y - vyprev ) * shrink + Math.random()
if @debug then console.log 'maxa',change_len, @maxa, shrink, x, y, vxprev, vyprev, newx, newy
Expand Down

0 comments on commit 7cbbff5

Please sign in to comment.