xxxxxxxxxx
45
// This Sketch combines Dan Shiffman's 'Flocking' example with Shawn Van Every's 'SimpleSimplePeer' Library
let myVideo;
let boids = [];
let constraints = {
video: {
width: {
ideal: 160
},
height: {
ideal: 120
},
frameRate: {
ideal: 10
}
}
}
function setup() {
createCanvas(windowWidth, windowHeight);
myVideo = createCapture(constraints,
function(stream) {
peer = new p5LiveMedia(this, "CAPTURE", stream, "myRoom")
peer.on('stream', gotStream);
}
);
myVideo.muted = true;
myVideo.hide();
boids.push(new Boid(width / 2, height / 2, myVideo));
}
function draw() {
background(220, 100, 150);
for (let i = 0; i < boids.length; i++) {
boids[i].run(boids);
}
}
// We got a new stream!
function gotStream(stream) {
boids.push(new Boid(width / 2, height / 2, stream));
}