xxxxxxxxxx
50
var bg;
var img;
var wid = 600//window.innerWidth;
var hei = 400//window.innerHeight;
function preload() {
img = loadImage('finalWorld.png');
}
var bugs = []; // array of Jitter objects
function setup() {
//img = loadImage('finalWorld.png');
background(img);
createCanvas(wid, hei);
//image(img,0,0);
// Create objects
for (var i=0; i<300; i++) {
bugs.push(new Jitter());
}
//background(0);
background(img);
}
function draw() {
for (var i=0; i<bugs.length; i++) {
bugs[i].move();
bugs[i].display();
}
}
// Jitter class
function Jitter() {
this.x = random(width);
this.y = random(height);
this.diameter = 2;
this.speed = 1;
this.move = function() {
this.x += random(-this.speed, this.speed);
this.y += random(-this.speed, this.speed);
};
this.display = function() {
noStroke();
fill(0);
ellipse(this.x, this.y, this.diameter, this.diameter);
};
}