Guest User

Untitled

a guest
Jan 15th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. Dot[] dots = new Dot[8];
  2. PVector attractor_pos;
  3.  
  4. void setup() {
  5. frameRate(60);
  6. size(800, 800);
  7. background(0);
  8. stroke(255);
  9. smooth();
  10.  
  11. initialize();
  12. }
  13.  
  14. class Dot {
  15. private PVector pos, vel, acc;
  16.  
  17. public Dot(float pos_x, float pos_y, float vel_x, float vel_y) {
  18. this.pos = new PVector(pos_x, pos_y);
  19. this.vel = new PVector(vel_x, vel_y);
  20. this.acc = new PVector(0,0);
  21. }
  22.  
  23. public void move() {
  24. this.pos.add(this.vel);
  25. this.vel.add(this.acc);
  26.  
  27. //private PVector dist = this.pos.sub(attractor_pos);
  28.  
  29. //this.acc.add(
  30. }
  31.  
  32. public void draw() {
  33. fill(255);
  34. ellipse(this.pos.x, this.pos.y, 4, 4);
  35. }
  36. }
  37.  
  38. public void initialize() {
  39. attractor_pos = new PVector(width/2, height/2);
  40. for (int i = 0; i < dots.length; i++) {
  41. dots[i] = (new Dot(random(width), random(height), random(-0.5, 0.5), random(-0.5, 0.5)));
  42. }
  43. }
  44.  
  45. void draw() {
  46. for (int i = 0; i < dots.length; i++) {
  47. Dot p = dots[i];
  48. p.draw();
  49. p.move();
  50. }
  51. }
Add Comment
Please, Sign In to add comment