comparison 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
comparison
equal deleted inserted replaced
61:ceaf645ed930 62:caf67c7e0814
492 g2.drawImage(lautaBGScaled, 0, 0, null); 492 g2.drawImage(lautaBGScaled, 0, 0, null);
493 widgets.paint(g2); 493 widgets.paint(g2);
494 494
495 if (!lauta.flagGameOver) 495 if (!lauta.flagGameOver)
496 { 496 {
497 // Draw next piece 497 if (lauta.nextPiece != null)
498 AffineTransform save = g2.getTransform(); 498 {
499 lauta.nextPiece.paint(g2, 830, 325, 90); 499 // Draw next piece
500 g2.setTransform(save); 500 AffineTransform save = g2.getTransform();
501 lauta.nextPiece.paint(g2, 830, 325, 90);
502 g2.setTransform(save);
503 }
501 } 504 }
502 else 505 else
503 { 506 {
504 // Game over text 507 // Game over text
505 String text = "Game Over!"; 508 String text = "Game Over!";
629 // Progress game animation clock 632 // Progress game animation clock
630 gameClock++; 633 gameClock++;
631 634
632 // Animate components 635 // Animate components
633 lauta.animate(gameClock); 636 lauta.animate(gameClock);
634 lauta.nextPiece.animate(gameClock); 637 if (lauta.nextPiece != null)
638 lauta.nextPiece.animate(gameClock);
635 639
636 // Repaint with a frame limiter 640 // Repaint with a frame limiter
637 if (gameClock % 4 == 1) 641 if (gameClock % 4 == 1)
638 { 642 {
639 repaint(); 643 repaint();