Why do i get assertion error on world.step();

import fisica.*;

FWorld world;

FCircle player;
FBox pipeup;
FBox pipedown;

class game {

  float x = pipeup.getX();
  float y = pipeup.getY();
  float x1 = pipedown.getX();
  float y1 = pipedown.getY();

  void update() {
    x -= 4;
    x1 -= 4;
    y = pipeup.getY();
    y1 = pipedown.getY();
    pipeup.setPosition(x,y);
    pipedown.setPosition(x1,y1);
    if(x + 50 < 0){
      x = 600;
    }
    if(x1 + 50 < 0){
      x1 = 600;
    }
  }
}

game game;

void setup() {
  size(480, 600);
  smooth();

  Fisica.init(this);

  world = new FWorld();
  world.setGravity(0, 500);

  pipeup = new FBox(50, 200);
  pipeup.setPosition(400, 100);
  pipeup.setRotation(0);
  pipeup.setFillColor(#808080);
  pipeup.setNoStroke();
  pipeup.setGrabbable(false);
  pipeup.setStatic(true);
  world.add(pipeup);
  
  pipedown = new FBox(50, -200);
  pipedown.setPosition(400, 500);
  pipedown.setRotation(0);
  pipedown.setFillColor(#808080);
  pipeup.setNoStroke();
  pipeup.setGrabbable(false);
  pipeup.setStatic(true);
  world.add(pipedown);

  player = new FCircle(40);
  player.setPosition(width/3, 200);
  player.setRotation(0);
  player.setFillColor(#808080);
  player.setNoStroke();
  player.setGrabbable(false);
  world.add(player);
  
  game = new game();
}

void draw() {
  background(0);
  world.step();
  game.update();
  world.draw();
}

void mousePressed() {
  player.addImpulse(0, -666);
}

Hello @processing_guy!

Your error is on this line:

...
pipedown = new FBox(50, -200);
pipedown.setPosition(400, 500);
...

You should input non-negative numbers into length and width when defining a new instance of FBox, so it should be FBox(50,200)

Also noticed you have a mistake in setting attributes of pipedown but for pipeup as well

...
  pipedown = new FBox(50, 200);
  pipedown.setPosition(400, 500);
  pipedown.setRotation(0);
  pipedown.setFillColor(#808080);
  pipeup.setNoStroke(); // <- right here
  pipeup.setGrabbable(false);
  pipeup.setStatic(true);
...
2 Likes

thanks man you helped me a lot