public void run(){
        final double GAME_HERTZ = 40.0;
        //final double TARGET_FPS = 60.0;
        final double TIME_BETWEEN_UPDATES = 1000 / GAME_HERTZ;
        final int MAX_FRAMESKIP = 5;

        long lastTime = System.currentTimeMillis();
        long currentTime = 0;
        long step = (long) TIME_BETWEEN_UPDATES;
        long sleepTime = 0;
        startInitialization();
        isRunning = true;

        while (isRunning){
            //currentTime = System.currentTimeMillis();
            //step = currentTime - lastTime;
            //lastTime = currentTime;
            if (startPressed) {
                update(step);
            }
            //step += TIME_BETWEEN_UPDATES;
            if (!gameFinnished) {
                render();
            } else {
                finishGame();
                if (startPressed) {
                    startInitialization();
                }
            }
            //sleepTime = lastTime - System.currentTimeMillis();

            if (sleepTime > 0)  {
                try {
                    Thread.sleep(sleepTime);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }