FreshRSS

Zobrazení pro čtení

Jsou dostupné nové články, klikněte pro obnovení stránky.

Connecting bodies together in jbox2d

Im trying to connect bodies together to make some sort of a "building" system or more specifically im trying to make multiple "blocks" connect to eachother but Struggling to figure out what's the best method to do it I tried using joints (created a jointDef and a joint) but I have no idea how. I can make a single large body but I want different parts of the body to have different friction values

Jbox2d simulation runs slowly

I wanted to use jbox2d for my project but I have a issue the physics simulation is running very slowly I tried to change game loops and it did not run any faster the best solution I found is still like half the speed it should be

game loop code (FPS = 60):

    double drawInterval = 1000000000/FPS;
    double delta = 0;
    long lastTime = System.nanoTime();
    long currentTime;
    while(thread != null) {
        currentTime = System.nanoTime();


        delta+= (currentTime-lastTime)/drawInterval;


        float md = (float) (delta/1000000.0);

        lastTime = currentTime;

        if(delta >= 1) {
            world.step((float)delta ,8,3);

            tick(delta);
            System.out.println("e");
            repaint();
            delta--;

        }

    }
❌