We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hullo. I am a 8th grader whose doing processing for an assignment. I saw a post by tfguy44 (Animated text) and the script for BouncyText. How do you make it stop at a certain Point? I would like it to stop in the middle of the canvas. Here's the script so far: class bouncyWord { String theWord; float px, py, vx, vy; bouncyWord(String iWord, float ipx) { theWord = iWord; px=ipx; vx=0; py=height/1; vy=random(2, 7); } void setup(){ size(450,450); } void draw() { px+=vx; py+=vy; if (py<0) { py=0; vy=-vy; } if (py>height) { py=height; vy=-vy; } text(theWord, px, py); } }
bouncyWord aa, bb, cc, dd, ee, ff;
void setup() {
size(220, 220);
textAlign(CENTER);
aa = new bouncyWord("nugget", width/4);
fill(255);
}
void draw() {
background(0);
aa.draw();
}
Answers
@Nugget -- Please edit your post, then highlight and format the code with CTRL-o. This will aid other forum members in reading and testing your code.
thanx
Have a look at the following changes:
I hope this helps,
Kf
http://studio.SketchPad.cc/sp/pad/view/ro.9eHY5Fel1e0Jr/latest
http://p5js.SketchPad.cc/sp/pad/view/ro.C1VbDaBKYgMV9-/latest
(you need a blank line before and after the code for it to show correctly. you need blank lines between paragraphs generally)