Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. class Star {
  2. float x; //using polar coordinates may have been better
  3. float y;
  4. float z;
  5. float r;
  6. int age = 2;
  7. Tail tail;
  8.  
  9. Star(boolean areTails, int tailLength) {
  10. x = random(-width / age, width / age);
  11. y = random(-height / age, height / age);
  12. while (x == 0) {
  13. x = random(-width / age, width / age);
  14. }
  15. while (y == 0) {
  16. y = random(-height / age, height / age);
  17. }
  18. z = random(1.003, 1.03);
  19. r = random(8, 10);
  20. tail = new Tail(areTails, tailLength, z, r);
  21. }
  22.  
  23. void update() {
  24. tail.update(x, y, r);
  25. if (x <= -width || x >= width || y <= -height || y >= height) {
  26. if (age < 8) {
  27. age++;
  28. }
  29. x = random(-width / age, width / age);
  30. y = random(-height / age, height / age);
  31. while (x == 0) {
  32. x = random(-width / age, width / age);
  33. }
  34. while (y == 0) {
  35. y = random(-height / age, height / age);
  36. }
  37. z = random(1.003, 1.03);
  38. r = random(8, 10);
  39. tail = new Tail(areTails, tailLength, z, r);
  40. }
  41. else {
  42. x *= z;
  43. y *= z;
  44. r *= (z * z - 1) * 0.08 + 1;
  45. }
  46. }
  47.  
  48. void show() {
  49. tail.show();
  50. fill(255);
  51. noStroke();
  52. ellipse(x, y, r, r);
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement