diff game/Engine.java @ 50:496e616ff09d

More work on IDMgui.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 22 Feb 2011 11:45:40 +0200
parents e6da5c71be28
children f81f76458b92
line wrap: on
line diff
--- a/game/Engine.java	Tue Feb 22 10:52:08 2011 +0200
+++ b/game/Engine.java	Tue Feb 22 11:45:40 2011 +0200
@@ -88,7 +88,7 @@
         score = 0;
         
         soundManager = smgr;
-        sndPlaced = soundManager.getSound("sounds/placed.wav");
+//        sndPlaced = soundManager.getSound("sounds/placed.wav");
     }
 
     public void paint(Graphics2D g, int sx, int sy, float scale)
@@ -253,6 +253,7 @@
 
     IDMContainer widgets;
     BtnNewGame btnNewGame;
+    BtnSwapPiece btnSwapPiece;
 
     public Engine()
     {
@@ -296,6 +297,9 @@
         btnNewGame = new BtnNewGame();
         widgets.add(btnNewGame);
 
+        btnSwapPiece = new BtnSwapPiece();
+        widgets.add(btnSwapPiece);
+
         // Game
         startNewGame();
         
@@ -347,21 +351,19 @@
 
             System.out.print("scale changed\n");
             
-            btnNewGame.move(dim.width - 200, dim.height - 100);
+            btnNewGame.move(dim.width - 200, dim.height - 150);
+            btnSwapPiece.move(dim.width - 200, dim.height - 400);
         }
         
         // Background, pieces
         g2.drawImage(lautaBGScaled, 0, 0, null);
         lauta.paint(g2, 100, 150, 60);
-
-        btnNewGame.paint(g2);
+        widgets.paint(g2);
         
         // Scores
         g2.setFont(font1);
         g2.setPaint(Color.white);
-        
-        
-        // Other elements
+
         long currTime = new Date().getTime();
         g2.drawString("fps = "+ ((gameFrames * 1000) / (currTime - startTime)), dim.width - 120, 20);
     }
@@ -471,4 +473,16 @@
             startNewGame();
         }
     }
+
+    class BtnSwapPiece extends IDMButton
+    {
+        public BtnSwapPiece()
+        {
+            super(0, 0, KeyEvent.VK_SPACE, font1, "Swap Piece");
+        }
+
+        public void clicked()
+        {
+        }
+    }
 }