Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dot[] dots = new Dot[8];
- PVector attractor_pos;
- void setup() {
- frameRate(60);
- size(800, 800);
- background(0);
- stroke(255);
- smooth();
- initialize();
- }
- class Dot {
- private PVector pos, vel, acc;
- public Dot(float pos_x, float pos_y, float vel_x, float vel_y) {
- this.pos = new PVector(pos_x, pos_y);
- this.vel = new PVector(vel_x, vel_y);
- this.acc = new PVector(0,0);
- }
- public void move() {
- this.pos.add(this.vel);
- this.vel.add(this.acc);
- //private PVector dist = this.pos.sub(attractor_pos);
- //this.acc.add(
- }
- public void draw() {
- fill(255);
- ellipse(this.pos.x, this.pos.y, 4, 4);
- }
- }
- public void initialize() {
- attractor_pos = new PVector(width/2, height/2);
- for (int i = 0; i < dots.length; i++) {
- dots[i] = (new Dot(random(width), random(height), random(-0.5, 0.5), random(-0.5, 0.5)));
- }
- }
- void draw() {
- for (int i = 0; i < dots.length; i++) {
- Dot p = dots[i];
- p.draw();
- p.move();
- }
- }
Add Comment
Please, Sign In to add comment