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