comparison game/Engine.java @ 180:fa9f29387cff

Implement a very simplistic message queue system.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 16 Mar 2017 12:22:30 +0200
parents ac5cf78a1cd2
children 2e033eced6e5
comparison
equal deleted inserted replaced
179:ac5cf78a1cd2 180:fa9f29387cff
501 Thread animThread; 501 Thread animThread;
502 boolean animEnable = false; 502 boolean animEnable = false;
503 503
504 GameBoard lauta = null; 504 GameBoard lauta = null;
505 InputStream musa; 505 InputStream musa;
506 IDMContainer widgets; 506 IDMWindow widgets;
507 AboutBox aboutBox; 507 AboutBox aboutBox;
508 508
509 public void dbg(String msg) 509 public void dbg(String msg)
510 { 510 {
511 System.out.print("Engine: " + msg); 511 System.out.print("Engine: " + msg);
550 550
551 dbg(e.getMessage()); 551 dbg(e.getMessage());
552 } 552 }
553 553
554 // Create IDM GUI widgets 554 // Create IDM GUI widgets
555 widgets = new IDMContainer(); 555 widgets = new IDMWindow();
556 556
557 lauta = new GameBoard(new IDMPoint(95, 130), 63); 557 lauta = new GameBoard(new IDMPoint(95, 130), 63);
558 widgets.add(lauta); 558 widgets.add(lauta);
559 559
560 widgets.add(new BtnSwapPiece(767f, 450f)); 560 widgets.add(new BtnSwapPiece(767f, 450f));
762 try { 762 try {
763 Thread.sleep(15); 763 Thread.sleep(15);
764 } 764 }
765 catch (InterruptedException x) { 765 catch (InterruptedException x) {
766 } 766 }
767
768 String msg;
769 do {
770 msg = widgets.getMessage();
771 if (msg != null && msg == "NEWGAME")
772 startNewGame();
773 } while (msg != null);
767 } 774 }
768 } 775 }
769 776
770 class BtnNewGame extends IDMButton 777 class BtnNewGame extends IDMButton
771 { 778 {
774 super(x, y, KeyEvent.VK_ESCAPE, G.fonts[1], "New Game"); 781 super(x, y, KeyEvent.VK_ESCAPE, G.fonts[1], "New Game");
775 } 782 }
776 783
777 public void clicked() 784 public void clicked()
778 { 785 {
779 startNewGame(); 786 sendMessage("NEWGAME");
780 } 787 }
781 } 788 }
782 789
783 class BtnSwapPiece extends IDMButton 790 class BtnSwapPiece extends IDMButton
784 { 791 {