I am currently programming my first game in Java and I'm having trouble structuring it. My biggest concern is regarding the game loop. Currently I have implemented a class with only a main function which first initializes all of the variables and then goes into a game loop. Here is the structure of the code:
public static void main(String args[])
//Initializing all the variables
//Main game loop
while(true)
{
if (mouse is pressed)
{
do something
}
if (mouse is released)
{
do something
}
......
}
The problem is that the "do something" parts are quite lengthy and my code looks quite messy. I would like to turn them into methods, however I am not really sure how to do it.
DoSomething()
method. Can you edit your question to go a bit more into the specifics of what kind of mess you want help cleaning up, and what obstacle you've found to putting related code into their own methods? \$\endgroup\$