What I had originally done (which has now been changed to something similar to this) was to have a timed loop that would go through each player in the list and either roll the dice or let them roll it. Since it was a TImer, it was sitting in its own thread.

Now that I've switched it to simply resume the game after each player is done with their turn and have it figure out who the next player is instead of using a timed loop.

Thanks everyone for the help, now I know a bit more about threads ;-).


On Dec 1, 2006, at 10:51 PM, Eric Biesterfeld wrote:

Why is this a thread-related issue? I'm a bit confused....

Your controller should be off in its own little world interacting with the view as necessary. The view should have a listener to tell it when to update. They're off in their own little worlds, with the controller and its listeners to the mouse, keyboard, and such.

The model, however, really simple. When controller calls it with new information, it wakes up. "Oh, hi, someone triggered the MouseListener!"

if (currentPlayer.isHuman()) {
  do stuff

(Of course, your controller should be looking at the model and if the player is a human, the dice rolling button should be activated as well.)

So, then, how does your model progress? Well, don't think of it as a loop, think of it as a nextTurn() call, each time, first triggered by the controller when it calls model.newGame(Players[] players);

Then newGame initializes the game and says player[0].yourTurn();

If it's a computer player, it calls the model directly and interacts automatically. If it's a human player, it gets its inputs from the controller, only progressing the game at the Controller's pace. ( player.rollDice(); player.buyProperty(true); player.endTurn ()) -- which, of course, calls model.nextTurn();

Or perhaps I'm missing the point?

On 12/1/06, Warner Onstine <[EMAIL PROTECTED]> wrote: Or at least someone who's smarter than me ;-). I'm stuck on a project
for school, essentially it is a Monopoly game. I have created a
separate thread that runs through the list of players and moves them.
If they are a computer player then it rolls the dice for them, but
for the human players I want to allow the user to click the dice.

I've tried a number of techniques to get the game thread to pause and
wait for the user to click the dice but they've either resulted in
pausing the entire game and locking up the interface or just ignoring
the other thread altogether.

Any assistance is greatly appreciated as this is my first real time
with threads and it is driving me absolutely batty!


To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to