Advertisement
bobzil

Drop

Sep 17th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. class Drop {
  2. float x = random(width*2);
  3. float y = random(-300, -100);
  4. float z = random(0, 30);
  5. float len = map(z, 0, 20, 19, 20);
  6. float yspeed = map(z, 15, 20, 8, 10);
  7.  
  8. void fall() {
  9. y = y+ yspeed;
  10. float grav = map(z, 0, 20, 0, 0.2);
  11. yspeed = yspeed + grav;
  12.  
  13. if ( y > height) {
  14. y = random(-200, -100);
  15. yspeed = map(z/4, 0, 20, 4, 10);
  16. }
  17. }
  18.  
  19. void show() {
  20.  
  21. float thick = map(z, 0, 40, 2, 3);
  22. strokeWeight(thick/2);
  23. stroke(mouseX, random(43, 230), mouseY);
  24. line(x-y, y+len, x-y+z*2, y-23);
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement