public static void launch() { stateList.add(new Menu()); Listener l = new Listener(); Constants.STAGE.addKeyListener(l); Constants.STAGE.addMouseMotionListener(l); Constants.STAGE.addMouseListener(l); loop(); }
private static void loop() { long dt = 0; long last = System.currentTimeMillis(); while (Constants.running) { dt = System.currentTimeMillis() - last; if (dt > 10) { last = System.currentTimeMillis(); if (stateList.size() != 0) stateList.get(stateList.size() - 1).update(dt); if (stateList.size() != 0) stateList.get(stateList.size() - 1).createImage(); if (stateList.size() != 0) stateList.get(stateList.size() - 1).draw(Constants.graphics); Constants.STAGE.repaint(); } } }