Advertisement
sakureis

ziyun

Apr 26th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. float x = 500;
  2. float y = 500;
  3. float speedX = 2;
  4. float speedY = 0.5f;
  5. float circleSize = 5;
  6.  
  7. public void setup(){
  8.  
  9. background(0xff80D7EA);
  10. }
  11.  
  12. public void draw(){
  13. // Behavior
  14.  
  15. fill(random(255), random(255), random(253, 150),75);
  16. stroke(random(255));
  17. x = x+speedX;
  18. y = y+speedY;
  19. circleSize = random(10, 45)/10;
  20.  
  21. // Drawing the ellipse
  22. ellipse(x, y, 35, 35);
  23.  
  24. //Reset the position
  25. x += speedX;
  26. if(x > width || x < 0){
  27. speedX *= -1;
  28. }
  29.  
  30. y += speedY;
  31. if(y > height || y < 0){
  32. speedY *= -1;
  33. }
  34. }
  35. public void settings() { size(500, 500); }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement