Thank you! The problem is solved, and I think I see clearly why. I will look into background processes later, and for now I'll go with the simple solution. Great!
/Martin Nilsson
----- Original Message ----- From: Bert Freudenberg Sent: 03/16/11 04:40 PM To: A friendly place to get answers to even the most basic questions about Squeak. Subject: Re: [Newbies] Strange bug with Morphic
On 16.03.2011, at 11:33, Martin Nilsson wrote:
Now, my question is: what magic does this call to Transcript do which causes my game to update correctly
It performs a "world cycle", which causes a redraw.
, and what message should I send instead to get the same effect, even without a Transcript window open ?
You could write "self world doOneCycleNow". However, this normally hints at a design flaw.
Morphic is an event-driven system. It has a main loop that processes events, then redraws the changed parts of the world.
Since your code does not "return" to the main loop while doing the AI, the UI will not update. The "proper" way would be doing the UI in a background process, which would notify the UI process when done. Then other things could happen in parallel to the AI "thinking".
If you don't care about the world being frozen while the AI is doing its thing, then you don't need a background process, and forcing a world cycle to update the display is fine. Certainly simpler.
- Bert -
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
beginners@lists.squeakfoundation.org