Created
April 26, 2011 11:23
-
-
Save medecau/942121 to your computer and use it in GitHub Desktop.
This file contains 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 fisica.*; | |
import processing.video.MovieMaker; | |
//MovieMaker mm; | |
FWorld world; | |
void setup(){ | |
size(800,600); | |
smooth(); | |
//mm = new MovieMaker(this, width, height, "demo.mov", | |
// 30, MovieMaker.ANIMATION, MovieMaker.HIGH); | |
Fisica.init(this); | |
world=new FWorld(); | |
world.setGravity(0,0); | |
FCircle s = new FCircle(40); | |
s.setPosition(width/2,height/2); | |
s.setStatic(true); | |
s.setFill(255,0,0); | |
world.add(s); | |
for (int i=0;i<10;i++){ | |
FCircle p = new FCircle(random(1,10)); | |
p.setVelocity(random(0,400),0); | |
p.setPosition(random(0,width),random(0,height)); | |
p.setDamping(0); | |
p.setFill(0,63,195); | |
world.add(p); | |
} | |
world.step(); // :( | |
ArrayList ps = world.getBodies(); | |
for (int i=0;i<ps.size();i++){ | |
for (int j=i+1;j<ps.size();j++){ | |
FDistanceJoint g = new FDistanceJoint((FCircle)ps.get(i),(FCircle)ps.get(j)); | |
g.setLength(0); | |
g.setFrequency(0.2); | |
g.setDamping(0); | |
g.setStroke(127); | |
world.add(g); | |
} | |
} | |
} | |
void draw(){ | |
background(255); | |
world.step(); | |
world.draw(); | |
//mm.addFrame(); | |
} | |
/* | |
void keyPressed() { | |
if (key == ' ') { | |
mm.finish(); | |
} | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment