Mercurial > hg > ristipolku
annotate game/Engine.java @ 49:e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 22 Feb 2011 10:52:08 +0200 |
parents | f13bab4cccd3 |
children | 496e616ff09d |
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; | |
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; |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
256 |
9 | 257 public Engine() |
2 | 258 { |
25 | 259 // Initialize globals |
260 System.out.print("Engine() constructor\n"); | |
261 | |
37 | 262 // Sound system |
47 | 263 soundManager = new SoundManager(sfmt, 16); |
9 | 264 |
25 | 265 // Load resources |
4 | 266 try |
267 { | |
24 | 268 ResourceLoader res = new ResourceLoader("graphics/board.jpg"); |
18 | 269 lautaBG = ImageIO.read(res.getStream()); |
21 | 270 |
25 | 271 try { |
272 res = new ResourceLoader("graphics/font.ttf"); | |
273 fontMain = Font.createFont(Font.TRUETYPE_FONT, res.getStream()); | |
274 font1 = fontMain.deriveFont(24f); | |
275 font2 = fontMain.deriveFont(32f); | |
276 } | |
277 catch (FontFormatException e) | |
278 { | |
279 System.out.print("Could not initialize fonts.\n"); | |
280 } | |
37 | 281 |
42
951a4d669af0
Initially working path solving algorithm.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
282 // musa = smgr.getSound("sounds/gamemusic.wav"); |
4 | 283 } |
284 catch (IOException e) | |
285 { | |
286 JOptionPane.showMessageDialog(null, | |
21 | 287 e.getMessage(), |
4 | 288 "Initialization error", |
289 JOptionPane.ERROR_MESSAGE); | |
37 | 290 |
21 | 291 System.out.print(e.getMessage()); |
18 | 292 } |
293 | |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
294 // 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
|
295 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
|
296 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
|
297 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
|
298 |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
299 // Game |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
300 startNewGame(); |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
301 |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
302 // Initialize event listeners |
18 | 303 addKeyListener(this); |
304 addMouseListener(this); | |
305 | |
306 // Get initial focus | |
307 if (!hasFocus()) | |
308 { | |
309 System.out.print("Engine(): requesting focus\n"); | |
310 requestFocus(); | |
4 | 311 } |
37 | 312 |
47 | 313 soundManager.play(musa); |
8 | 314 } |
315 | |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
316 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
|
317 { |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
318 gameClock = 0; |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
319 gameFrames = 0; |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
320 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
|
321 |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
322 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
|
323 } |
25 | 324 |
325 public void paintComponent(Graphics g) | |
326 { | |
327 Graphics2D g2 = (Graphics2D) g; | |
328 | |
329 // Use antialiasing when rendering the game elements | |
330 g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, | |
331 RenderingHints.VALUE_ANTIALIAS_ON); | |
332 | |
333 g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, | |
334 RenderingHints.VALUE_TEXT_ANTIALIAS_ON); | |
335 | |
336 // Rescale background if component size has changed | |
337 Dimension dim = getSize(); | |
338 if (lautaDim == null || !dim.equals(lautaDim)) | |
339 { | |
340 lautaBGScaled = new BufferedImage(dim.width, dim.height, BufferedImage.TYPE_INT_ARGB); | |
341 Graphics2D gimg = lautaBGScaled.createGraphics(); | |
342 gimg.setRenderingHint(RenderingHints.KEY_INTERPOLATION, | |
343 RenderingHints.VALUE_INTERPOLATION_BICUBIC); | |
344 | |
345 gimg.drawImage(lautaBG, 0, 0, dim.width, dim.height, null); | |
346 lautaDim = dim; | |
347 | |
348 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
|
349 |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
350 btnNewGame.move(dim.width - 200, dim.height - 100); |
25 | 351 } |
352 | |
353 // Background, pieces | |
354 g2.drawImage(lautaBGScaled, 0, 0, null); | |
355 lauta.paint(g2, 100, 150, 60); | |
356 | |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
357 btnNewGame.paint(g2); |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
358 |
25 | 359 // Scores |
360 g2.setFont(font1); | |
361 g2.setPaint(Color.white); | |
362 | |
363 | |
364 // Other elements | |
365 long currTime = new Date().getTime(); | |
32
e480579cc460
More work on debugging the path resolving.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
366 g2.drawString("fps = "+ ((gameFrames * 1000) / (currTime - startTime)), dim.width - 120, 20); |
25 | 367 } |
368 | |
8 | 369 public void startThreads() |
370 { | |
9 | 371 System.out.print("startThreads()\n"); |
8 | 372 if (animThread == null) |
373 { | |
374 animThread = new Thread(this); | |
375 animEnable = true; | |
376 animThread.start(); | |
377 } | |
378 } | |
379 | |
380 public void stopThreads() | |
381 { | |
9 | 382 System.out.print("stopThreads()\n"); |
37 | 383 |
384 // Stop animations | |
8 | 385 if (animThread != null) |
386 { | |
387 animThread.interrupt(); | |
388 animEnable = false; | |
389 animThread = null; | |
390 } | |
22 | 391 |
37 | 392 // Shut down sound manager |
47 | 393 soundManager.close(); |
2 | 394 } |
0 | 395 |
18 | 396 public void mouseEntered(MouseEvent e) { } |
397 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
|
398 |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
399 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
|
400 { |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
401 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
|
402 } |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
403 |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
404 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
|
405 { |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
406 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
|
407 } |
18 | 408 |
409 public void mouseClicked(MouseEvent e) | |
410 { | |
411 System.out.print("mouseClicked()\n"); | |
412 if (!hasFocus()) | |
413 { | |
414 System.out.print("requesting focus\n"); | |
415 requestFocus(); | |
416 } | |
417 } | |
418 | |
9 | 419 public void keyTyped(KeyEvent e) |
2 | 420 { |
421 } | |
1 | 422 |
2 | 423 public void keyReleased(KeyEvent e) |
424 { | |
425 } | |
1 | 426 |
9 | 427 public void keyPressed(KeyEvent e) |
2 | 428 { |
26
3d4cc47df31a
Cleanups, fix piece rendering and rotation.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
429 // 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
|
430 if (lauta.keyPressed(e)) |
47 | 431 return; |
432 | |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
433 widgets.keyPressed(e); |
2 | 434 } |
8 | 435 |
436 public void run() | |
437 { | |
438 while (animEnable) | |
439 { | |
26
3d4cc47df31a
Cleanups, fix piece rendering and rotation.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
440 // Progress game animation clock |
25 | 441 gameClock++; |
9 | 442 |
26
3d4cc47df31a
Cleanups, fix piece rendering and rotation.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
443 // Animate components |
25 | 444 lauta.animate(gameClock); |
9 | 445 |
26
3d4cc47df31a
Cleanups, fix piece rendering and rotation.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
446 // Repaint with a frame limiter |
25 | 447 if (gameClock % 3 == 1) |
24 | 448 { |
10 | 449 repaint(); |
25 | 450 gameFrames++; |
24 | 451 } |
32
e480579cc460
More work on debugging the path resolving.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
452 |
26
3d4cc47df31a
Cleanups, fix piece rendering and rotation.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
453 // Sleep for a moment |
9 | 454 try { |
455 Thread.sleep(10); | |
456 } | |
457 catch (InterruptedException x) { | |
458 } | |
8 | 459 } |
460 } | |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
461 |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
462 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
|
463 { |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
464 public BtnNewGame() |
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 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
|
467 } |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
468 |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
469 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
|
470 { |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
471 startNewGame(); |
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 } |
0 | 474 } |