public void run() {
		init();

		long lt = System.nanoTime();
		double nsPt = 1000000000.0 / 60.0;
		double d = 0.0;
		int ticks = 0;
		int frames = 0;
		long ltr = System.currentTimeMillis();
		boolean shouldRender = false;

		while (running) {
			long now = System.nanoTime();
			d += (now - lt) / nsPt;
			lt = now;
			shouldRender = false;

			while (d >= 1) {
				tick();
				ticks++;
				d--;
				shouldRender = true;
			}

			if (shouldRender) {
				render();
				frames++;
			}

			long cur = System.currentTimeMillis();
			if (cur - ltr >= 1000) {
				ltr += 1000;
				boolean isApp = (Boolean) GlobalVariables.get("isApplet");
				if (!isApp)
					frame.setTitle(NAME + " " + ticks + " tps, " + frames + " fps");
				ticks = frames = 0;
			}
		}
	}