Squeak and Children

Jecel Assumpcao Jr jecel at merlintec.com
Tue Nov 28 17:50:19 UTC 2000


Mark,

great draft chapter! By coincidence, I have always used the falling
object example to explain Morphic (in Self). I don't know what your
intended audience is, but when creating the example for people who have
had some high school physics I like to use points for acceleration and
velocity. The code is just as simple as what you presented (to the
amazement of those who have tried something like this in some other
language):


    step
                     velocity _ velocity + gravity.
                     self bounds: (self bounds translateBy: velocity).

where you have set velocity to 0 at 1 or something. Now you can start with
a horizontal velocity and get the nice parabola with no extra coding!
In fact, with a slight patch in the above method to always have gravity
pointing to some object (instead of straight down) you can plunge
directly into celestial mechanics (and no - I don't mean SMTP ;-)

-- Jecel





More information about the Squeak-dev mailing list