Advanced game loop for java projects