Looks l;ike a very interesting bug starting with ballGame = new BallGame();
in main.
First, new BallGame()
is called. That constructor calls Renderer.repaint()
which executes BallGame.ballGame.Repaint(g);
then, and only then, after the constructor has returned, the variable ballGame
is set to refer to the new BallGame.
So when you execute BallGame.ballGame.Repaint(g);
, ballGame
is still null and you get an NPE
ps You still need a Timer, not a loop!