public void actionPerformed(ActionEvent e) {
            Object source = e.getSource();
            if (source == timer) {
                // perform a loop through the game's logic
                synchronized (this) {
                    if (timerReady) {
                        timerReady = false;
                        if (midiPlayer == null)
                            log.d("MidiPlayer is null");
                        currentLevel.timerLoop();//timerLoop();
                        repaint();
                        timerReady = true;
                    }

                }

                // Logic for Frames per Second counter

                this.ticks++;

                long currentTime = System.currentTimeMillis();

                if (currentTime - startTime >= 500) {
                    prevFPS = 1000.0 * ticks / (1.0 * currentTime - startTime);
                    if (FPS) {
                        log.d(String.valueOf(prevFPS));
                        //todo
                    }
                    startTime = currentTime;
                    ticks = 0;
                }

                lastTime = currentTime;
            }
        }