Public Member Functions | |
void | startIt () |
To start the Timer. | |
void | interrupt () |
void | lvlup () |
To advance to the next lvl. | |
Package Functions | |
timer (Tetris tetris, int intervalTick, int intervalDrop) | |
Package Attributes | |
Thread | tickTimer |
The thread that is responsible for the regular time ticks in the game. | |
Thread | dropTimer |
The thread that is responsible for the continous falling. | |
Private Attributes | |
int | intervalTick |
The Variable to hold the tick speed. | |
int | intervalDrop |
The Variable to hold the drop speed. | |
Tetris | tetris |
The Variable to hold the tetris. | |
boolean | running = false |
to stopp the stuff. | |
Classes | |
class | GameOverEventListener |
The listener to listen to the game over event and to stopp the time if one occured. More... |
engine.timer.timer | ( | Tetris | tetris, | |
int | intervalTick, | |||
int | intervalDrop | |||
) | [package] |
tetris | The Tetris to call the methods. | |
intervalTick | The initial tickspeed. | |
intervalDrop | The initial speed a Stone drops. |
00061 { 00062 this.intervalTick = intervalTick; 00063 this.intervalDrop = intervalDrop; 00064 this.tetris = tetris; 00065 GameOverEvent.addGameOverListener(new GameOverEventListener()); 00066 }
void engine.timer.startIt | ( | ) |
To start the Timer.
References engine.timer.dropTimer, engine.timer.running, and engine.timer.tickTimer.
00114 { 00115 if (tickTimer.getState().compareTo(Thread.State.NEW) == 0) { 00116 running = true; 00117 tickTimer.start(); 00118 dropTimer.start(); 00119 } 00120 }
void engine.timer.interrupt | ( | ) |
References engine.timer.running.
Referenced by engine.JavaRenderer.keyPressed().
00122 { 00123 running = false; 00124 // tickTimer.stop(); 00125 // System.out.println(tickTimer.getState()); 00126 }
void engine.timer.lvlup | ( | ) |
To advance to the next lvl.
References engine.timer.intervalDrop, and engine.timer.intervalTick.
00131 { 00132 intervalTick -= (intervalTick / 4); 00133 intervalDrop -= (intervalDrop / 4); 00134 }
int engine.timer.intervalTick [private] |
int engine.timer.intervalDrop [private] |
Tetris engine.timer.tetris [private] |
The Variable to hold the tetris.
boolean engine.timer.running = false [private] |
to stopp the stuff.
Referenced by engine.timer.GameOverEventListener.gameOver(), engine.timer.interrupt(), and engine.timer.startIt().
Thread engine.timer.tickTimer [package] |
Initial value:
new Thread() { @Override public void run() { while (running) { if (!Tetris.down) { tetris.tickEvent(); } try { Thread.sleep(intervalTick); } catch (InterruptedException e) { e.printStackTrace(); } } this.interrupt(); } }
Referenced by engine.timer.startIt().
Thread engine.timer.dropTimer [package] |
Initial value:
new Thread() { @Override public void run() { while (running) { if (Tetris.down) { tetris.dropStone(); } try { Thread.sleep(intervalDrop); } catch (InterruptedException e) { e.printStackTrace(); } } this.interrupt(); } }
Referenced by engine.timer.startIt().