-
Notifications
You must be signed in to change notification settings - Fork 0
Les conditions (if)
DENIS LE FUR edited this page Feb 22, 2019
·
3 revisions
Lien vers l'exemple suivant : https://editor.p5js.org/dlefur@gmail.com/sketches/oxLCKZ_3d
let k=1; // coefficient du sens
let r=25; //rayon de la balle
let x=r; // déplacement horizontale
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
// test si la balle sort à droite
if (x>width-r){
k=-1;
}
// test si la balle sort à gauche
if (x<r) {
k=1;
}
x=x+k*5;
translate(x,200);
ellipse(0,0,2*r,2*r);
}