Hello
Any update about this issue? I am facing the issue even with velocity 2, 3! The number of balls is 4 though!
Also, I would like to know how the velocity of the ball is affected in a bounceOff function (tried to print the same)
My code for reference
/creating the balls at the four corners.
var ball1 = createSprite(5,5,10,10);
var ball2 = createSprite(395,5,10,10);
var ball3 = createSprite(395,395,10,10);
var ball4 = createSprite(5,395,10,10);
//coloring the balls with different shades.
ball1.shapeColor = “red”;
ball2.shapeColor = “blue”;
ball3.shapeColor = “lightgreen”;
ball4.shapeColor = “orange”;
//setting the velocity of the balls to
//trigger movement towards the centre.
ball1.velocityX = 2;
ball1.velocityY = 2;
ball2.velocityX = -2;
ball2.velocityY = -2;
ball3.velocityX = 3;
ball3.velocityY = 3;
ball4.velocityX = 2;
ball4.velocityY = -3;
function draw() {
//clearing the screen
background(“white”);
//creating the edges
createEdgeSprites();
//making the balls bounceoff the edges.
ball1.bounceOff(edges);
ball2.bounceOff(edges);
ball3.bounceOff(edges);
ball4.bounceOff(edges);
//ball1 bouncing off the other balls.
ball1.bounceOff(ball2);
ball1.bounceOff(ball3);
ball1.bounceOff(ball4);
//ball2 bouncing off the other balls.
ball2.bounceOff(ball3);
ball2.bounceOff(ball4);
//ball3 bouncing off ball4
ball3.bounceOff(ball4);
text(“Ball1.VelocityX=”+ball1.velocityX,50,20);
text(“Ball1.VelocityY=”+ball1.velocityY,50,40);
text(“Ball2.VelocityX=”+ball2.velocityX,50,60);
text(“Ball2.VelocityY=”+ball2.velocityY,50,80);
text(“Ball3.VelocityX=”+ball3.velocityX,50,100);
text(“Ball3.VelocityY=”+ball3.velocityY,50,120);
text(“Ball4.VelocityX=”+ball4.velocityX,50,140);
text(“Ball4.VelocityY=”+ball4.velocityY,50,160);
drawSprites();
}