Create a draw() function inside other function in Javascript Processing -
ok, have piece of code:
var = 0; var left = random(width); var right = left +50; var pos = left; var isleft = true; var draw= function() { background(255, 0, 0); fill(255, 0, 0); strokeweight(2); stroke(255, 255, 255); ellipse(pos,400-a,10,10); a=a+0.5; if (isleft === true) { pos +=0.5; } if (pos === right) { isleft = false; } if (isleft === false) { pos -=0.5; } if (pos === left) { isleft = true; } };
basically create bubble floats upwards while moving left , right little bit. idea make happens/starts when click mouse. don't seem know how. still learning how code. can me produce desired effect.
thanks , sorry bad english.
if want happen if click anywhere example should work you:
document.body.addeventlistener("click", draw, false);
Comments
Post a Comment