public void run() {
		init();
		
		
		double nsPerFrame = 1000000000D / 60D;
		double unprocessedTime = 0;
		double maxSkipFrame = 10;

		long lastTime = System.nanoTime();
		long lastFrameTime = System.currentTimeMillis();
		int frames = 0;
		int ticks = 0;
		
		while (running) {
			long now = System.nanoTime();
			double passedTime = (now - lastTime) / nsPerFrame;
			lastTime = now;

			if (passedTime < -maxSkipFrame) passedTime = -maxSkipFrame;
			if (passedTime > maxSkipFrame) passedTime = maxSkipFrame;

			unprocessedTime += passedTime;

			boolean render = true;

			while (unprocessedTime > 1) {
				unprocessedTime -= 1;
				mouse = input.updateMouseStatus(SCALE);
				EntityListCache.reset();
				tick();
				ticks++;
				render = true;
			}

			if (render) {
				EntityListCache.reset();
				render(screenBitmap);
				frames++;
			}

			if (System.currentTimeMillis() - lastFrameTime > 1000) {
				lastFrameTime += 1000;
				System.out.println("fps: " + frames + ", ticks: " + ticks);
				ticks = 0;
				frames = 0;
			}

			try {
				Thread.sleep(2);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			swap();
		}
	}