Small change to Flock example.

This commit is contained in:
Jonathan Puckey 2011-04-28 21:13:51 +02:00
parent de466edc23
commit 3751dd0a38

View file

@ -20,6 +20,8 @@
head.strokeColor = null; head.strokeColor = null;
var headSymbol = new Symbol(head); var headSymbol = new Symbol(head);
var size = document.size;
var Boid = Base.extend({ var Boid = Base.extend({
initialize: function(position, maxSpeed, maxForce) { initialize: function(position, maxSpeed, maxForce) {
var strength = Math.random() * 0.5; var strength = Math.random() * 0.5;
@ -129,8 +131,8 @@
var loc = this.loc, var loc = this.loc,
r = this.r, r = this.r,
oldLoc = this.loc.clone(), oldLoc = this.loc.clone(),
width = document.size.width, width = size.width,
height = document.size.height; height = size.height;
if (loc.x < -r) loc.x = width + r; if (loc.x < -r) loc.x = width + r;
if (loc.y < -r) loc.y = height + r; if (loc.y < -r) loc.y = height + r;
if (loc.x > width + r) loc.x = -r; if (loc.x > width + r) loc.x = -r;
@ -281,7 +283,7 @@
// Resize the document, whenever the window is resized, // Resize the document, whenever the window is resized,
window.onresize = function(event) { window.onresize = function(event) {
document.size = [window.innerWidth, window.innerHeight]; size = document.size = [window.innerWidth, window.innerHeight];
heartPath.position = document.bounds.center; heartPath.position = document.bounds.center;
document.redraw(); document.redraw();
} }