public void run() {
		long currenttime;
		long previoustime = System.nanoTime();
		long passedtime;
		int frames = 0;
		double unprocessedseconds = 0;
		double secondspertick = 1 / 60.0;
		int tickcount = 0;
		boolean ticked = false;

		while (isRunning) {
			currenttime = System.nanoTime();
			passedtime = currenttime - previoustime;
			previoustime = currenttime;
			unprocessedseconds += passedtime / 1000000000.0;

			while (unprocessedseconds > secondspertick) {
				tick();
				unprocessedseconds -= secondspertick;
				ticked = true;
				tickcount++;
				globalTicks++;
				if (tickcount % 60 == 0) {
					System.out.println(frames + " FPS " + tickcount + " TPS");
					previoustime += 1000;
					frames = 0;
					tickcount = 0;
				}
			}
			if (ticked) {
				render();
				frames++;
			}
		}
	}