Creating of Thread + splitting game into 2 classes.

Hi, I’ve decided that i want to pauze my game and i’ll use thread.pauze.
I created it because otherwise all the code will go in the Game class, So I would like to have the Manager ‘Manage’ the game.
When I say Manage I think of creating stopping pauzing replaying and controlling keybord activity.
The main game loop itself is in Game.
Is this the right way to split the two classes?

This is a code snippet from my Game_Management class:

  private Game game;
  private Thread GameThread;

  /** Creates and Controls a Game */
  Public Game_Management() {
    bFact = new BlockFactory();
    board = new Board(20,10,Block.TILE_SIZE);
    game = new Game(this,board,bFact);
    startGame();
  }

  public void startGame() {
    /* Initialize the game thread. */
    GameThread = new GameThread();
    GameThread.start();
  }

  private class GameThread extends Thread {
    public void run() {
      game.run();
    }
  }

Next I have to use the inner class to use Thread but when I try to start it gives me his error:

Exception in thread "main" java.lang.ClassNotFoundException: Game_Management
	at java.net.URLClassLoader$1.run(URLClassLoader.java:200)

How do I start a thread and do therun method in another class?
Error sorted, I put package in my classes so it couldn’t find the class anymore.

alsoo is it smart to put those 2 things appart?
For more Info I created a javadoc Documentation and I put the src online
Any comment is welcome :wink:

If you want to pause the game… simply stop calling tick() (or whatever your logic method is called)… render the game as usual and if paused, render “paused” on top.

It really can be this simple. :slight_smile:

srry, i don’t see it 8)

When the guy behind the keybord pressed p he wants to pauze.
so if p=true then stop calling my run loop. No more code runs nothing happens.
Now he returns and presses p again to go on, but how do i continue, there is nothing there? I stopped my loop…

or do you mean keep on running all the code except the run function but wouldn’t that be a waste?

Whats wrong with thread.pauze? ???

alsoo i found this page http://www.theorphys.science.ru.nl/people/fasolino/sub_java/pendula/Classes/nl/kun/Engine3D/TickTimer.html wich has a counter and it looks excactly what i need, but it’s not within the jdk (i can’t find it…)

while(running){
  if(paused)
    checkUnpause();
  else
    tick();
  render();
  if(paused)
    renderPauseShizzle();
}

I see ;D