comparison game/Engine.java @ 147:0ec311706d3c

Clean up debug messages.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 26 Nov 2011 11:25:46 +0200
parents f01cb1ea26a5
children 5b25561855c3
comparison
equal deleted inserted replaced
146:351f20e09d48 147:0ec311706d3c
595 GameBoard lauta = null; 595 GameBoard lauta = null;
596 InputStream musa; 596 InputStream musa;
597 IDMContainer widgets; 597 IDMContainer widgets;
598 AboutBox aboutBox; 598 AboutBox aboutBox;
599 599
600 public void dbg(String msg)
601 {
602 System.out.print("Engine: " + msg);
603 }
604
600 public Engine() 605 public Engine()
601 { 606 {
602 // Initialize globals 607 // Initialize globals
603 System.out.print("Engine() constructor\n"); 608 System.out.print("Engine() constructor\n");
604 609
620 G.fonts[2] = G.fonts[0].deriveFont(64f); 625 G.fonts[2] = G.fonts[0].deriveFont(64f);
621 G.fonts[3] = G.fonts[0].deriveFont(32f); 626 G.fonts[3] = G.fonts[0].deriveFont(32f);
622 } 627 }
623 catch (FontFormatException e) 628 catch (FontFormatException e)
624 { 629 {
625 System.out.print("Could not initialize fonts.\n"); 630 dbg("Could not initialize fonts.\n");
626 } 631 }
627 632
628 res = new ResourceLoader("sounds/gamemusic.wav"); 633 res = new ResourceLoader("sounds/gamemusic.wav");
629 musa = res.getStream(); 634 musa = res.getStream();
630 } 635 }
633 JOptionPane.showMessageDialog(null, 638 JOptionPane.showMessageDialog(null,
634 e.getMessage(), 639 e.getMessage(),
635 "Initialization error", 640 "Initialization error",
636 JOptionPane.ERROR_MESSAGE); 641 JOptionPane.ERROR_MESSAGE);
637 642
638 System.out.print(e.getMessage()); 643 dbg(e.getMessage());
639 } 644 }
640 645
641 // Create IDM GUI widgets 646 // Create IDM GUI widgets
642 widgets = new IDMContainer(); 647 widgets = new IDMContainer();
643 648
662 G.smgr.play(musa); 667 G.smgr.play(musa);
663 668
664 // Get initial focus 669 // Get initial focus
665 if (!hasFocus()) 670 if (!hasFocus())
666 { 671 {
667 System.out.print("Engine(): requesting focus\n"); 672 dbg("Requesting focus.\n");
668 requestFocus(); 673 requestFocus();
669 } 674 }
670 675
671 gameUpdates = 0; 676 gameUpdates = 0;
672 } 677 }
699 // Rescale fonts 704 // Rescale fonts
700 G.fonts[1] = G.fonts[0].deriveFont(24f * dw); 705 G.fonts[1] = G.fonts[0].deriveFont(24f * dw);
701 G.fonts[2] = G.fonts[0].deriveFont(64f * dw); 706 G.fonts[2] = G.fonts[0].deriveFont(64f * dw);
702 G.fonts[3] = G.fonts[0].deriveFont(32f * dw); 707 G.fonts[3] = G.fonts[0].deriveFont(32f * dw);
703 708
704 System.out.print("scale changed\n"); 709 dbg("Scale changed.\n");
705 scaleChanged = true; 710 scaleChanged = true;
706 updateBoard = true; 711 updateBoard = true;
707 } 712 }
708 713
709 if (updateBoard) 714 if (updateBoard)
710 { 715 {
711 // System.out.print("updateBoard()\n"); 716 // dbg("updateBoard()\n");
712 G.lautaBGScaled = new BufferedImage(dim.width, dim.height, BufferedImage.TYPE_INT_RGB); 717 G.lautaBGScaled = new BufferedImage(dim.width, dim.height, BufferedImage.TYPE_INT_RGB);
713 Graphics2D gimg = G.lautaBGScaled.createGraphics(); 718 Graphics2D gimg = G.lautaBGScaled.createGraphics();
714 gimg.setRenderingHint(RenderingHints.KEY_INTERPOLATION, 719 gimg.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
715 RenderingHints.VALUE_INTERPOLATION_BICUBIC); 720 RenderingHints.VALUE_INTERPOLATION_BICUBIC);
716 721
754 gameFrames++; 759 gameFrames++;
755 } 760 }
756 761
757 public void startThreads() 762 public void startThreads()
758 { 763 {
759 System.out.print("startThreads()\n"); 764 dbg("startThreads()\n");
760 if (animThread == null) 765 if (animThread == null)
761 { 766 {
762 animThread = new Thread(this); 767 animThread = new Thread(this);
763 animEnable = true; 768 animEnable = true;
764 animThread.start(); 769 animThread.start();
765 } 770 }
766 } 771 }
767 772
768 public void stopThreads() 773 public void stopThreads()
769 { 774 {
770 System.out.print("stopThreads()\n"); 775 dbg("stopThreads()\n");
771 776
772 // Stop animations 777 // Stop animations
773 if (animThread != null) 778 if (animThread != null)
774 { 779 {
775 animThread.interrupt(); 780 animThread.interrupt();
808 813
809 public void mouseClicked(MouseEvent e) 814 public void mouseClicked(MouseEvent e)
810 { 815 {
811 if (!hasFocus()) 816 if (!hasFocus())
812 { 817 {
813 System.out.print("Requesting focus\n"); 818 dbg("Requesting focus.\n");
814 requestFocus(); 819 requestFocus();
815 } 820 }
816 } 821 }
817 822
818 public void mouseWheelMoved(MouseWheelEvent e) 823 public void mouseWheelMoved(MouseWheelEvent e)