engine.timer Class Reference

This class is doing all the stuff that has something to do with timing. More...

Collaboration diagram for engine.timer:

Collaboration graph
[legend]

List of all members.

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...


Detailed Description

This class is doing all the stuff that has something to do with timing.

Author:
Team Solid Sun

Constructor & Destructor Documentation

engine.timer.timer ( Tetris  tetris,
int  intervalTick,
int  intervalDrop 
) [package]

Parameters:
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         }


Member Function Documentation

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         }


Member Data Documentation

The Variable to hold the tick speed.

Referenced by engine.timer.lvlup().

The Variable to hold the drop speed.

Referenced by engine.timer.lvlup().

The Variable to hold the tetris.

boolean engine.timer.running = false [private]

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();
                }
        }
The thread that is responsible for the regular time ticks in the game.

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();
                }
        }
The thread that is responsible for the continous falling.

Referenced by engine.timer.startIt().


The documentation for this class was generated from the following file:

Generated on Mon Jul 28 19:03:04 2008 for SolidJavaTetris by  doxygen 1.5.5