World edges in Fisica (not holding up)

edited August 2014 in Library Questions

Hello, I'm new to Fisica.
I am trying to create a sketch with limited amount of circles inside a container, eventually I will be able to drag them and do some actions on them. At the moment I have two problems, which probably results from one main problem (but I am curious to know the answer to the second question too).
1. Once i've added the circle to the world it continues to generate unlimited amount of circles, and never stops. I've tried to limit it with a for loop but it didn't work. I'm probably missing something really basic here.
2. I have created edges to the world intending to limit the area for the circles. After a lot of circles are being generated they somehow exit the borders and spill outside. I was wondering, why does this happens?

import fisica.*;
 FWorld world;

void setup() {
  size(400, 400);
  Fisica.init(this);
  world = new FWorld();
  world.setEdges(20,20,300,350,#FFCC00);
}

void draw() {
  world.step(1.5);
  world.draw();
  FCircle myCircle = new FCircle(40);
  myCircle.setPosition(width/2, height/2);
// for (int i = 40; i < 80; i = i+1) {
  world.add(myCircle);
  myCircle.setVelocity(150, 0);
 //}
  world.setGravity(0, 20);
}

Thanks in advance.

Answers

  • Answer ✓

    Dunno that library. But somehow I've come up w/ this:

    // forum.processing.org/two/discussion/6743/
    // world-edges-in-fisica-not-holding-up
    
    import fisica.*;
    FWorld world;
    FCircle myCircle;
    
    void setup() {
      size(400, 400, JAVA2D);
      frameRate(60);
      smooth(4);
    
      Fisica.init(this);
    
      world = new FWorld();
      world.setEdges(20, 20, width-20, height-20, #FFCC00);
      world.setGravity(-3, 2);
    
      myCircle = new FCircle(30);
      world.add(myCircle);
      myCircle.setPosition(width>>1, height>>1);
      myCircle.setVelocity(15, -30);
    }
    
    void draw() {
      background(0300);
      world.step(.1);
      world.draw();
    }
    
Sign In or Register to comment.