xxxxxxxxxx
var bubbles = [];
var img;
var capture;
var x,y,r,c;
function preload() {
img = loadImage('bubble.png');
}
function setup() {
createCanvas(400,300);
for (var i = 0; i < 0; i++) {
bubbles[i] = new Bubble(random(width), random(height));
}
capture = createCapture(VIDEO);
capture.size(width, height);
}
function draw() {
background(0);
loadPixels();
image(capture, 0, 0, width, height);
for (var i = 0; i < bubbles.length; i++) {
bubbles[i].move();
bubbles[i].display();
}
}
function mousePressed() {
bubbles.push(new Bubble(mouseX, mouseY, img));
}
function keyPressed() {
bubbles = [];
}
function Bubble(x,y, img) {
this.x = x;
this.y = y;
this.img = img;
this.display = function() {
imageMode(CENTER);
image(this.img, this.x, this.y)
}
this.move = function() {
this.x = this.x + random(-1,1);
this.y = this.y + random(-1,1);
}
}