So, my JFrame becomes unresponsive when I run this code. I managed to trace it back to the while loop under gameLoop(). Regardless of using delay(1000/FRAMERATE) which calls
You are performing Thread.sleep()
in your main thread which in this case is the EDT (Event Dispatcher Thread). This thread is responsible for painting your graphics and listening to events. By doing Thread.sleep()
you are essentially pausing it, thus not allowing it to do it's job.
It seems that you want to refresh your GUI at intervals (at least that is what I am guessing). If this is the case, you will need to move your logic to a new separate thread and then, call what ever update methods you will need from the thread you will have spawned off. To make changes visible, you will need to call the event dispatcher thread again by using the SwingUtilities.invokeLater() method.