Help with morph and world refresh
Stephane Ducasse
ducasse at iam.unibe.ch
Sat Apr 5 08:37:01 UTC 2003
Hi all
for my small robot environment I define the following method so that a
bot can move from one tile to another one.
Bot>>go
| nextPosition |
nextPosition := self nextPosition.
self goTo: nextPosition.
World doOneCycle.
self motorSound
When I remove the line World doOneCycle,
writing Bot new go; go; go; go
makes the bot moving but the user does not see it and only sees it at
the end of the move.
Now I have other robot actions such as canPick (to test whether it can
pick a diamond) and pick to really pick a diamond.
With the World doOneCycle in the go method, it may happen that when I
execute fast
b2 go.
b2 canPick
ifTrue: [b2 pick].
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.
I have the impression that this is a really bad practice to explicitly
wait for the refresh but I do not know how to do it in a better way.
Have you suggestion to fix my problem?
Stef
Prof. Dr. Stéphane DUCASSE
http://www.iam.unibe.ch/~ducasse/
"if you knew today was your last day on earth, what would you do
different? ... especially if,
by doing something different, today might not be your last day on
earth" Calvin&Hobbes
"The best way to predict the future is to invent it..." Alan Kay.
Open Source Smalltalks: http://www.squeak.org,
http://www.gnu.org/software/smalltalk/smalltalk.html
Free books for Universities at
http://www.esug.org/sponsoring/promotionProgram.html
Free Online Book at
http://www.iam.unibe.ch/~ducasse/WebPages/FreeBooks.html
More information about the Squeak-dev
mailing list
|