Help with morph and world refresh

Ned Konz ned at
Sat Apr 5 17:10:10 UTC 2003

On Saturday 05 April 2003 08:27 am, Stephane Ducasse wrote:

> In fact the problem with not pick the diamonds only occurs if I
> execute from a workspace really fast multiple times the expression
> b2 go.
> b2 canPick ifTrue: [b2 pick]
> This suggests to me that I'm executing several commands at the same
> time.

If these are done as part of the same World cycle, then you won't see 
the display update until after the last one. You could do something 
like forcing the changes to the screen in between, but there are 
probably better ways to do it.

You could try adding this for testing, at least:

	Display forceToScreen: myMorph bounds; forceDisplayUpdate

This will force any invalidated regions to be redrawn visibly.

> >> the bot misses to pick some diamonds: really annoying. I guess
> >> that this is because the method can pick and pick do not contain
> >> World doOneCycle.

Does it really miss doing something, or just not show that it is doing 

> Nathanael already did that for the turtle with animation that I
> have. But this is really complex.
> I'm amazed to see how difficult it is to simply do a stupid small
> program
> in Squeak that requires animation (ok I do not use step). 

Animation when combined with a display that caches changes requires 
some kind of synchronization.

> Still.  I'm not sure that I can really develop your solution but 
thanks for
> suggesting it. When I read it, I'm really frustrated by my lack of 
concurrent programming skills.

Concurrent programming isn't easy in general. One of the nice things 
about the eToy system (though it certainly has a number of 
limitations) is that it presents concurrent programming in a fashion 
that is easy to get right (no explicit synchronization).

In Morphic, there's a simplifying assumption that everything is 
happening in a single Process.

This is the reason that most of the time step is the best choice, if 
you can use it. The display is forced to the screen at the end of 
every world cycle.

> Would the WorldState>>addDeferredUIMessage: solve my problem?

Not necessarily, as these messages are processed at the beginning of 
the World's update cycle. If there are multiple messages which each 
will move your Morph you won't see the intermediate position.

Ned Konz

More information about the Squeak-dev mailing list