Mercurial > hg > ristipolku
diff game/Engine.java @ 62:caf67c7e0814
Fix a possible null pointer exception under certain circumstances.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 24 Feb 2011 03:59:46 +0200 |
parents | 4a984e3b27d2 |
children | dc936dba124e |
line wrap: on
line diff
--- a/game/Engine.java Thu Feb 24 03:58:33 2011 +0200 +++ b/game/Engine.java Thu Feb 24 03:59:46 2011 +0200 @@ -494,10 +494,13 @@ if (!lauta.flagGameOver) { - // Draw next piece - AffineTransform save = g2.getTransform(); - lauta.nextPiece.paint(g2, 830, 325, 90); - g2.setTransform(save); + if (lauta.nextPiece != null) + { + // Draw next piece + AffineTransform save = g2.getTransform(); + lauta.nextPiece.paint(g2, 830, 325, 90); + g2.setTransform(save); + } } else { @@ -631,7 +634,8 @@ // Animate components lauta.animate(gameClock); - lauta.nextPiece.animate(gameClock); + if (lauta.nextPiece != null) + lauta.nextPiece.animate(gameClock); // Repaint with a frame limiter if (gameClock % 4 == 1)