xxxxxxxxxx
29
//https://discourse.processing.org/t/assignment-operator/10249
// what is the meaning of "assignment condition"
// assignment statement " (ball.yCor+rad == pad.yPaddle) " ???
let ballxCor = 0, ballyCor = 0, rad = 20;
let padxPaddle = 200, padyPaddle = 300, w = 200, h = 80;
function setup() {
createCanvas(400, 400);
noStroke();
}
function draw() {
background(200, 200, 0);
// ball and movement
ballyCor = mouseY;
ballxCor = mouseX;
if (ballyCor + rad >= padyPaddle) { // if ( condition true )
ballyCor = padyPaddle - rad; // assingment ( here like limiter )
fill(200, 0, 0)
} else {
fill(0, 200, 0);
}
circle(ballxCor, ballyCor, rad);
// paddle fix
fill(0,0,200);
rect(padxPaddle, padyPaddle, w, h);
}