Created
November 13, 2013 13:02
-
-
Save dimkir/7448759 to your computer and use it in GitHub Desktop.
Created using Sketch2Tweet tool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is comment with sketch screenshot url: