Hi Ken,
Actually, the way I would like to deal with this problem is more along the lines of exposing something like a "script clock" which can be used to figure out when the script was last invoked. This would allow you to provide movement with constant speed simply via:
foo forward by (timer's elapsedTime * foo's speed)
Within eToys, this is actually a simple reification of the clock we already have in scripts - if a script is ticking it is essentially driven by events from that clock and, really, there is no reason why a script shouldn't be able to refer to its clock. At this point, there are various interesting avenues to follow - one might say, for example, that all of the script clocks use an "object clock" to get their own ticks which allows you to "slow down" entire objects. Etc. There's lots of fun stuff in this area ;-)
Cheers, - Andreas
----- Original Message ----- From: "Ken Kahn" kenkahn@toontalk.com To: "Andreas Raab" andreas.raab@squeakland.org; "Randy Heiland" heiland@indiana.edu; "'Squeakland'" squeakland@squeakland.org Sent: Sunday, February 29, 2004 7:58 PM Subject: Re: [Squeakland] drive-a-car newbie questions
Andreas -
Hi and thanks.
The alternative that I chose for ToonTalk is that when a user doesn't care about the relationship of real time and simulation time then they can do something similar to eToys and just change things by a constant on each cycle. But when they do care they can move forward a constant times the duration of the most recent cycle. This makes real time and simulation time identical at the cost of a bit more complex programming idiom. (Actually in the case of speed there is a built-in that does this for you, but the problem then returns if you want to program a constant acceleration.)
I lean towards the idea of encouraging kids to explicitly program to account for the passage of real time but my colleagues in WebLabs are sceptical and rather hide this complexity. Maybe explicitly relating real time and simulation time is a good learning oppurtunity for kids.
Best,
-ken kahn