コード例 #1
0
 @Override
 public void move(Body body) {
   Objects.requireNonNull(body);
   if (!hasBeenCalled) {
     Vec2 v2 = new Vec2(0.0f, 2.0f);
     body.setLinearVelocity(v2);
     hasBeenCalled = true;
   }
 }
コード例 #2
0
  @Override
  public void move(Body body) {
    Objects.requireNonNull(body);

    Vec2 v2 = new Vec2(2f, 0f);
    switch (nbCall) {
      case -1:
        nbCall++;
        break;
      case 0:
        if (body.getPosition().y * EscapeWorld.SCALE > (FrontApplication.WIDTH / 3 - 120)) {
          return;
        }
        v2.set(2f, 0f);
        break;
      case 1:
        if (body.getPosition().x * EscapeWorld.SCALE < (FrontApplication.WIDTH / 3)) {
          return;
        }
        v2.set(0f, 2f);
        break;
      case 2:
        if (body.getPosition().y * EscapeWorld.SCALE < (FrontApplication.WIDTH / 3)) {
          return;
        }
        v2.set(-2f, 0f);
        break;
      case 3:
        if (body.getPosition().x * EscapeWorld.SCALE > (FrontApplication.WIDTH / 3 - 120)) {
          return;
        }
        v2.set(0f, -2f);
        break;
      default:
        throw new AssertionError();
    }

    body.setLinearVelocity(v2);
    nbCall = (nbCall + 1) % 4;
  }