Mercurial > hg > ristipolku
annotate 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 |
rev | line source |
---|---|
0 | 1 /* |
9 | 2 * Ristipolku Game Engine |
0 | 3 * (C) Copyright 2011 Matti 'ccr' Hämäläinen <ccr@tnsp.org> |
4 */ | |
9 | 5 package game; |
6 | |
0 | 7 import java.awt.*; |
8 import java.awt.geom.*; | |
1 | 9 import java.awt.event.*; |
7 | 10 import java.awt.image.*; |
11 import java.awt.event.*; | |
25 | 12 import java.awt.font.*; |
9 | 13 import javax.imageio.*; |
7 | 14 import javax.swing.*; |
1 | 15 import java.util.*; |
6 | 16 import java.io.*; |
1 | 17 import game.*; |
37 | 18 import javax.sound.sampled.*; |
21 | 19 |
42
951a4d669af0
Initially working path solving algorithm.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
20 |
8 | 21 /* |
22 class AnimatedElement | |
23 { | |
24 float x, y, stime, value; | |
25 Interpolate lerp; | |
26 boolean active; | |
27 | |
28 public AnimatedElement(float x, float y, ) | |
29 { | |
30 stime = 0; | |
31 this.x = x; | |
32 this.y = y; | |
33 | |
34 } | |
35 | |
36 public animate(float time) | |
37 { | |
38 if (!active) | |
39 { | |
40 active = true; | |
41 stime = time; | |
42 } | |
43 | |
44 float t = (time - stime) / 10.0f; | |
45 if (t < 100) | |
46 value = lerp.getValue(t); | |
47 else | |
48 { | |
49 | |
50 } | |
51 } | |
52 | |
53 public paint(Graphics2D g, ); | |
54 { | |
55 } | |
56 } | |
57 */ | |
0 | 58 |
48 | 59 class GameBoard extends IDMWidget |
0 | 60 { |
2 | 61 public static final int boardSize = 9; |
62 public static final int boardMiddle = 4; | |
63 Piece[][] board; | |
42
951a4d669af0
Initially working path solving algorithm.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
64 |
8 | 65 public boolean flagGameOver; |
7 | 66 |
41 | 67 Piece currPiece; |
68 int currX, currY, currPoint; | |
9 | 69 |
48 | 70 int score; |
71 | |
47 | 72 SoundManager soundManager; |
73 Sound sndPlaced; | |
74 | |
75 public GameBoard(SoundManager smgr) | |
2 | 76 { |
77 board = new Piece[boardSize][boardSize]; | |
78 | |
79 board[boardMiddle][boardMiddle] = new Piece(PieceType.START); | |
80 | |
41 | 81 currX = boardMiddle; |
42
951a4d669af0
Initially working path solving algorithm.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
82 currY = boardMiddle; |
951a4d669af0
Initially working path solving algorithm.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
83 currPoint = 0; |
8 | 84 |
9 | 85 pieceFinishTurn(); |
8 | 86 |
87 flagGameOver = false; | |
48 | 88 score = 0; |
47 | 89 |
90 soundManager = smgr; | |
50 | 91 // sndPlaced = soundManager.getSound("sounds/placed.wav"); |
2 | 92 } |
0 | 93 |
7 | 94 public void paint(Graphics2D g, int sx, int sy, float scale) |
2 | 95 { |
96 for (int y = 0; y < boardSize; y++) | |
97 for (int x = 0; x < boardSize; x++) | |
98 if (board[x][y] != null) | |
99 { | |
6 | 100 AffineTransform save = g.getTransform(); |
101 | |
4 | 102 board[x][y].paint(g, |
103 sx + (x * scale), | |
104 sy + (y * scale), | |
105 scale - scale / 10); | |
6 | 106 |
107 g.setTransform(save); | |
2 | 108 } |
109 } | |
9 | 110 |
111 public void animate(float time) | |
112 { | |
113 for (int y = 0; y < boardSize; y++) | |
114 for (int x = 0; x < boardSize; x++) | |
115 if (board[x][y] != null) | |
116 { | |
117 board[x][y].animate(time); | |
118 } | |
10 | 119 |
9 | 120 } |
1 | 121 |
32
e480579cc460
More work on debugging the path resolving.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
122 public void pieceRotate(Piece.RotateDir dir) |
2 | 123 { |
41 | 124 if (currPiece != null) |
125 currPiece.rotate(dir); | |
2 | 126 } |
1 | 127 |
42
951a4d669af0
Initially working path solving algorithm.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
128 private void pieceMoveTo(int point) |
7 | 129 { |
46 | 130 switch (point) |
131 { | |
132 case 0: currY--; break; | |
133 case 1: currY--; break; | |
134 | |
135 case 2: currX++; break; | |
136 case 3: currX++; break; | |
137 | |
138 case 4: currY++; break; | |
139 case 5: currY++; break; | |
140 | |
141 case 6: currX--; break; | |
142 case 7: currX--; break; | |
143 } | |
42
951a4d669af0
Initially working path solving algorithm.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
144 } |
9 | 145 |
48 | 146 public boolean pieceCheck(Piece curr) |
147 { | |
148 if (curr == null) | |
149 { | |
150 // Create new piece | |
151 currPiece = new Piece(PieceType.ACTIVE); | |
152 board[currX][currY] = currPiece; | |
153 return true; | |
154 } | |
155 else | |
156 if (curr.getType() == PieceType.START) | |
157 { | |
158 if (currPiece != null) | |
159 { | |
160 // Hit center starting piece, game over | |
161 flagGameOver = true; | |
162 currPiece = null; | |
163 System.out.print("GameOver!\n"); | |
164 return true; | |
165 } | |
166 else | |
167 { | |
168 // Start piece as first piece means game is starting | |
169 pieceMoveTo(currPoint); | |
170 currPiece = new Piece(PieceType.ACTIVE); | |
171 board[currX][currY] = currPiece; | |
172 return true; | |
173 } | |
174 } | |
175 | |
176 // Mark the current piece as locked | |
177 curr.setType(PieceType.LOCKED); | |
178 | |
179 // Solve connection (with rotations) through the piece | |
180 currPoint = curr.getRotatedPoint(curr.getMatchingPoint(currPoint)); | |
181 | |
182 // Mark connection as active | |
183 curr.setConnectionState(currPoint, true); | |
184 | |
185 // Solve exit point (with rotations) | |
186 currPoint = curr.getAntiRotatedPoint(curr.getConnection(currPoint)); | |
187 | |
188 // Move to next position accordingly | |
189 pieceMoveTo(currPoint); | |
190 return false; | |
191 } | |
192 | |
42
951a4d669af0
Initially working path solving algorithm.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
193 public void pieceFinishTurn() |
951a4d669af0
Initially working path solving algorithm.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
194 { |
48 | 195 boolean finished = false; |
196 while (!finished) | |
7 | 197 { |
42
951a4d669af0
Initially working path solving algorithm.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
198 if (currX >= 0 && currX < boardSize && currY >= 0 && currY < boardSize) |
27 | 199 { |
48 | 200 finished = pieceCheck(board[currX][currY]); |
27 | 201 } |
202 else | |
203 { | |
46 | 204 // Outside of the board, game over |
48 | 205 finished = true; |
42
951a4d669af0
Initially working path solving algorithm.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
206 flagGameOver = true; |
47 | 207 currPiece = null; |
42
951a4d669af0
Initially working path solving algorithm.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
208 System.out.print("GameOver!\n"); |
7 | 209 } |
210 } | |
42
951a4d669af0
Initially working path solving algorithm.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
211 } |
47 | 212 |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
213 public boolean keyPressed(KeyEvent e) |
47 | 214 { |
215 switch (e.getKeyCode()) | |
216 { | |
217 case KeyEvent.VK_LEFT: | |
218 case KeyEvent.VK_UP: | |
219 pieceRotate(Piece.RotateDir.LEFT); | |
220 return true; | |
221 | |
222 case KeyEvent.VK_RIGHT: | |
223 case KeyEvent.VK_DOWN: | |
224 pieceRotate(Piece.RotateDir.RIGHT); | |
225 return true; | |
226 | |
227 case KeyEvent.VK_ENTER: | |
228 soundManager.play(sndPlaced); | |
229 pieceFinishTurn(); | |
230 return true; | |
231 } | |
232 return false; | |
233 } | |
1 | 234 } |
235 | |
236 | |
9 | 237 public class Engine extends JPanel |
18 | 238 implements Runnable, KeyListener, MouseListener |
1 | 239 { |
25 | 240 long startTime; |
241 float gameClock, gameFrames; | |
8 | 242 Thread animThread; |
243 boolean animEnable = false; | |
25 | 244 |
245 Font fontMain, font1, font2; | |
4 | 246 GameBoard lauta = null; |
9 | 247 BufferedImage lautaBG = null, lautaBGScaled = null; |
25 | 248 Dimension lautaDim; |
22 | 249 |
37 | 250 static final AudioFormat sfmt = new AudioFormat(22050, 16, 1, true, false); |
47 | 251 SoundManager soundManager; |
252 Sound musa; | |
1 | 253 |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
254 IDMContainer widgets; |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
255 BtnNewGame btnNewGame; |
50 | 256 BtnSwapPiece btnSwapPiece; |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
257 |
9 | 258 public Engine() |
2 | 259 { |
25 | 260 // Initialize globals |
261 System.out.print("Engine() constructor\n"); | |
262 | |
37 | 263 // Sound system |
47 | 264 soundManager = new SoundManager(sfmt, 16); |
9 | 265 |
25 | 266 // Load resources |
4 | 267 try |
268 { | |
24 | 269 ResourceLoader res = new ResourceLoader("graphics/board.jpg"); |
18 | 270 lautaBG = ImageIO.read(res.getStream()); |
21 | 271 |
25 | 272 try { |
273 res = new ResourceLoader("graphics/font.ttf"); | |
274 fontMain = Font.createFont(Font.TRUETYPE_FONT, res.getStream()); | |
275 font1 = fontMain.deriveFont(24f); | |
276 font2 = fontMain.deriveFont(32f); | |
277 } | |
278 catch (FontFormatException e) | |
279 { | |
280 System.out.print("Could not initialize fonts.\n"); | |
281 } | |
37 | 282 |
42
951a4d669af0
Initially working path solving algorithm.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
283 // musa = smgr.getSound("sounds/gamemusic.wav"); |
4 | 284 } |
285 catch (IOException e) | |
286 { | |
287 JOptionPane.showMessageDialog(null, | |
21 | 288 e.getMessage(), |
4 | 289 "Initialization error", |
290 JOptionPane.ERROR_MESSAGE); | |
37 | 291 |
21 | 292 System.out.print(e.getMessage()); |
18 | 293 } |
294 | |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
295 // UI IDM widgets |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
296 widgets = new IDMContainer(); |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
297 btnNewGame = new BtnNewGame(); |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
298 widgets.add(btnNewGame); |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
299 |
50 | 300 btnSwapPiece = new BtnSwapPiece(); |
301 widgets.add(btnSwapPiece); | |
302 | |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
303 // Game |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
304 startNewGame(); |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
305 |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
306 // Initialize event listeners |
18 | 307 addKeyListener(this); |
308 addMouseListener(this); | |
309 | |
310 // Get initial focus | |
311 if (!hasFocus()) | |
312 { | |
313 System.out.print("Engine(): requesting focus\n"); | |
314 requestFocus(); | |
4 | 315 } |
37 | 316 |
47 | 317 soundManager.play(musa); |
8 | 318 } |
319 | |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
320 public void startNewGame() |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
321 { |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
322 gameClock = 0; |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
323 gameFrames = 0; |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
324 startTime = new Date().getTime(); |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
325 |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
326 lauta = new GameBoard(soundManager); |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
327 } |
25 | 328 |
329 public void paintComponent(Graphics g) | |
330 { | |
331 Graphics2D g2 = (Graphics2D) g; | |
332 | |
333 // Use antialiasing when rendering the game elements | |
334 g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, | |
335 RenderingHints.VALUE_ANTIALIAS_ON); | |
336 | |
337 g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, | |
338 RenderingHints.VALUE_TEXT_ANTIALIAS_ON); | |
339 | |
340 // Rescale background if component size has changed | |
341 Dimension dim = getSize(); | |
342 if (lautaDim == null || !dim.equals(lautaDim)) | |
343 { | |
344 lautaBGScaled = new BufferedImage(dim.width, dim.height, BufferedImage.TYPE_INT_ARGB); | |
345 Graphics2D gimg = lautaBGScaled.createGraphics(); | |
346 gimg.setRenderingHint(RenderingHints.KEY_INTERPOLATION, | |
347 RenderingHints.VALUE_INTERPOLATION_BICUBIC); | |
348 | |
349 gimg.drawImage(lautaBG, 0, 0, dim.width, dim.height, null); | |
350 lautaDim = dim; | |
351 | |
352 System.out.print("scale changed\n"); | |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
353 |
50 | 354 btnNewGame.move(dim.width - 200, dim.height - 150); |
355 btnSwapPiece.move(dim.width - 200, dim.height - 400); | |
25 | 356 } |
357 | |
358 // Background, pieces | |
359 g2.drawImage(lautaBGScaled, 0, 0, null); | |
360 lauta.paint(g2, 100, 150, 60); | |
50 | 361 widgets.paint(g2); |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
362 |
25 | 363 // Scores |
364 g2.setFont(font1); | |
365 g2.setPaint(Color.white); | |
50 | 366 |
25 | 367 long currTime = new Date().getTime(); |
32
e480579cc460
More work on debugging the path resolving.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
368 g2.drawString("fps = "+ ((gameFrames * 1000) / (currTime - startTime)), dim.width - 120, 20); |
25 | 369 } |
370 | |
8 | 371 public void startThreads() |
372 { | |
9 | 373 System.out.print("startThreads()\n"); |
8 | 374 if (animThread == null) |
375 { | |
376 animThread = new Thread(this); | |
377 animEnable = true; | |
378 animThread.start(); | |
379 } | |
380 } | |
381 | |
382 public void stopThreads() | |
383 { | |
9 | 384 System.out.print("stopThreads()\n"); |
37 | 385 |
386 // Stop animations | |
8 | 387 if (animThread != null) |
388 { | |
389 animThread.interrupt(); | |
390 animEnable = false; | |
391 animThread = null; | |
392 } | |
22 | 393 |
37 | 394 // Shut down sound manager |
47 | 395 soundManager.close(); |
2 | 396 } |
0 | 397 |
18 | 398 public void mouseEntered(MouseEvent e) { } |
399 public void mouseExited(MouseEvent e) { } | |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
400 |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
401 public void mousePressed(MouseEvent e) |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
402 { |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
403 widgets.mousePressed(e); |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
404 } |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
405 |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
406 public void mouseReleased(MouseEvent e) |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
407 { |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
408 widgets.mouseReleased(e); |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
409 } |
18 | 410 |
411 public void mouseClicked(MouseEvent e) | |
412 { | |
413 System.out.print("mouseClicked()\n"); | |
414 if (!hasFocus()) | |
415 { | |
416 System.out.print("requesting focus\n"); | |
417 requestFocus(); | |
418 } | |
419 } | |
420 | |
9 | 421 public void keyTyped(KeyEvent e) |
2 | 422 { |
423 } | |
1 | 424 |
2 | 425 public void keyReleased(KeyEvent e) |
426 { | |
427 } | |
1 | 428 |
9 | 429 public void keyPressed(KeyEvent e) |
2 | 430 { |
26
3d4cc47df31a
Cleanups, fix piece rendering and rotation.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
431 // Handle keyboard input |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
432 if (lauta.keyPressed(e)) |
47 | 433 return; |
434 | |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
435 widgets.keyPressed(e); |
2 | 436 } |
8 | 437 |
438 public void run() | |
439 { | |
440 while (animEnable) | |
441 { | |
26
3d4cc47df31a
Cleanups, fix piece rendering and rotation.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
442 // Progress game animation clock |
25 | 443 gameClock++; |
9 | 444 |
26
3d4cc47df31a
Cleanups, fix piece rendering and rotation.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
445 // Animate components |
25 | 446 lauta.animate(gameClock); |
9 | 447 |
26
3d4cc47df31a
Cleanups, fix piece rendering and rotation.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
448 // Repaint with a frame limiter |
25 | 449 if (gameClock % 3 == 1) |
24 | 450 { |
10 | 451 repaint(); |
25 | 452 gameFrames++; |
24 | 453 } |
32
e480579cc460
More work on debugging the path resolving.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
454 |
26
3d4cc47df31a
Cleanups, fix piece rendering and rotation.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
455 // Sleep for a moment |
9 | 456 try { |
457 Thread.sleep(10); | |
458 } | |
459 catch (InterruptedException x) { | |
460 } | |
8 | 461 } |
462 } | |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
463 |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
464 class BtnNewGame extends IDMButton |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
465 { |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
466 public BtnNewGame() |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
467 { |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
468 super(0, 0, KeyEvent.VK_ESCAPE, font1, "New Game"); |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
469 } |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
470 |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
471 public void clicked() |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
472 { |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
473 startNewGame(); |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
474 } |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
475 } |
50 | 476 |
477 class BtnSwapPiece extends IDMButton | |
478 { | |
479 public BtnSwapPiece() | |
480 { | |
481 super(0, 0, KeyEvent.VK_SPACE, font1, "Swap Piece"); | |
482 } | |
483 | |
484 public void clicked() | |
485 { | |
486 } | |
487 } | |
0 | 488 } |