Skip to content

Instantly share code, notes, and snippets.

@dimkir
Created November 13, 2013 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dimkir/7448759 to your computer and use it in GitHub Desktop.
Save dimkir/7448759 to your computer and use it in GitHub Desktop.
Created using Sketch2Tweet tool
//import org.twitshot.*;
Mover mm;
Attractor aa;
void setup(){
size(1024, 768);
//Twitshot.spawn(this);
smooth();
aa = new Attractor(width/2, height/2, 155);
mm = new Mover(random(width), random(height), 10 + random(10));
aa.setMaxVelocity(5.0);
}
void draw(){
//background(128,10);
fill(128,10);
rectMode(LEFT);
rect(0,0, width, height);
attractorTowardsMouse();
PVector f = aa.attract(mm);
mm.applyForce(f);
PVector dir = PVector.sub(aa.location,mm.location);
if ( dir.mag() < 100 ){
mm.velocity.mult(0);
}
aa.draw();
mm.draw();
}
PVector vMouse = new PVector(0,0);
void attractorTowardsMouse(){
vMouse.set(mouseX, mouseY, 0.0); // we set it here, so that we don't have to init it each draw loop
vMouse.sub(aa.location);
vMouse.normalize();
vMouse.mult(5);
aa.applyForce(vMouse);
}
@dimkir
Copy link
Author

dimkir commented Nov 13, 2013

This is comment with sketch screenshot url: imge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment