xxxxxxxxxx
46
// The Nature of Code
// Daniel Shiffman
// http://natureofcode.com
// Example 1-2: Bouncing Ball, with p5.Vector!
let ball = [];
let oButton;
let gButton;
function setup() {
//frameRate(12);
createCanvas(320, 240);
oButton = createButton("orange");
oButton.mousePressed(
function() {
for (var i = 0; i < 10; i++) {
ball.push( createOrange() );
}
}
);
gButton = createButton("grapefruit");
gButton.mousePressed(
function() {
ball.push( createGrapefruit() );
}
);
}
function draw() {
background(255);
for (var i = 0; i < ball.length; i++) {
ball[i].update();
ball[i].display();
}
} // end draw
function mouseClicked() {
// ball.push( createBall() );
}