package nl.rutgerkok.physicssimulation.swing;

import static nl.rutgerkok.physicssimulation.Vector.vec2;
import static nl.rutgerkok.physicssimulation.shape.Circle.circle;
import static nl.rutgerkok.physicssimulation.shape.Rectangle.rectangle;
import static nl.rutgerkok.physicssimulation.world.PhysicalObject.obj;

import javax.swing.JFrame;
import javax.swing.Timer;

import nl.rutgerkok.physicssimulation.shape.Material;
import nl.rutgerkok.physicssimulation.world.PhysicsWorld;

public final class SwingStartup {

    public static void main(String... args) {
        JFrame window = new JFrame();
        window.setSize(800, 600);
        window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        window.setTitle("PhysicsSimulation");

        PhysicsWorld world = new PhysicsWorld();
        world.addObject(obj(circle(vec2(100, 100), 30), vec2(60, 0), Material.METAL));
        world.addObject(obj(circle(vec2(300, 100), 30), vec2(1, 1), Material.SUPERBALL));
        world.addObject(obj(rectangle(vec2(0, 400), vec2(700, 405)), vec2(0, -15), Material.WOOD));
        world.addObject(obj(rectangle(vec2(50, 500), vec2(200, 520)), vec2(5, -20), Material.ROCK));
        window.setContentPane(new DrawPanel(world));

        new Timer(100, event -> {
            world.advance(0.1);
            window.repaint();
        }).start();

        window.setVisible(true);
    }
}

@@ -510,16 +510,55 @@
 rtup %7B%0A%0A
+    public static final int FPS = 10;%0A%0A
     publ
@@ -1279,16 +1279,23 @@
 imer(100
+0 / FPS
 , event 
@@ -1329,11 +1329,24 @@
 nce(
-0.1
+1 / (double) FPS
 );%0A 

Make FPS a constant