@Override
    public void run() {
        long lastTime = System.nanoTime();
        long currTime = 0;
        double nsPerTick = 1000000000D/(double)ticksPerSecond;
        double delta = 0;
        
        while(running) {  
            currTime = System.nanoTime();
            delta += (currTime-lastTime)/nsPerTick;
            lastTime = currTime;
            
            while(delta>= 1) {
            delta--;
            //System.out.println(state.name());
                switch(state) {
                    case STANDBY:
                        loopStandBy();
                        break;
                    case PLAYING:
                        loopPlaying();
                        break;
                    case LOADING:
                        loadGame();
                        break;
                    case UNLOADING:
                        unloadGame();
                        break;
                    case EXIT:
                        break;
                    default:
                        break;
                }
            }
        }
    }