Mercurial > hg > ristipolku
comparison game/Engine.java @ 26:3d4cc47df31a
Cleanups, fix piece rendering and rotation.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 01 Feb 2011 19:18:25 +0200 |
parents | bbac3e4a4b9b |
children | 26adc2827983 |
comparison
equal
deleted
inserted
replaced
25:bbac3e4a4b9b | 26:3d4cc47df31a |
---|---|
363 { | 363 { |
364 } | 364 } |
365 | 365 |
366 public void keyPressed(KeyEvent e) | 366 public void keyPressed(KeyEvent e) |
367 { | 367 { |
368 // Handle keyboard input | |
368 switch (e.getKeyCode()) | 369 switch (e.getKeyCode()) |
369 { | 370 { |
370 case KeyEvent.VK_LEFT: | 371 case KeyEvent.VK_LEFT: |
371 case KeyEvent.VK_UP: | 372 case KeyEvent.VK_UP: |
372 lauta.pieceRotate(false); | 373 lauta.pieceRotate(false); |
387 | 388 |
388 public void run() | 389 public void run() |
389 { | 390 { |
390 while (animEnable) | 391 while (animEnable) |
391 { | 392 { |
393 // Progress game animation clock | |
392 gameClock++; | 394 gameClock++; |
393 | 395 |
396 // Animate components | |
394 lauta.animate(gameClock); | 397 lauta.animate(gameClock); |
395 | 398 |
399 // Repaint with a frame limiter | |
396 if (gameClock % 3 == 1) | 400 if (gameClock % 3 == 1) |
397 { | 401 { |
398 repaint(); | 402 repaint(); |
399 gameFrames++; | 403 gameFrames++; |
400 } | 404 } |
401 | 405 |
406 // Sleep for a moment | |
402 try { | 407 try { |
403 Thread.sleep(10); | 408 Thread.sleep(10); |
404 } | 409 } |
405 | |
406 catch (InterruptedException x) { | 410 catch (InterruptedException x) { |
407 } | 411 } |
408 } | 412 } |
409 } | 413 } |
410 } | 414 } |