Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!shelby!agate!spam.berkeley.edu!lippin From: lippin@spam.berkeley.edu (The Apathist) Newsgroups: comp.sys.mac.programmer Subject: Re: Animation Message-ID: <1991Feb3.093825.29969@agate.berkeley.edu> Date: 3 Feb 91 09:38:25 GMT References: <9102030237.AA06275@enuxha.eas.asu.edu> Sender: usenet@agate.berkeley.edu (USENET Administrator) Reply-To: lippin@math.berkeley.edu Organization: Authorized Service, Incorporated Lines: 41 Recently trotter@enuxha.eas.asu.edu (Russell T. Trotter) wrote: >What is the best way to do animation if I am relying on >the main event loop for the updates for the motion? > >I have tried various combinations of CopyBits(), >PutIcon, DrawPicture(),...etc, but they all >seem to be too flickery. Am I just doing >something fundamentally wrong? The most common cause of flicker is trying to animate by erasing and redrawing an object -- you can get away with this on a very small scale, but on a larger scale the viewer will see some background through the object in between the steps. Sometimes you can do a little better by drawing the new image before erasing the old; the eye tricks itself into ignoring the ghosts sometimes. But a better way is to get the stuff on the screen right the first time. Combine your background and foreground off screen, and copy both the old and new areas onto the screen at the same time. A second problem that can arise is that moving objects may get torn in half -- the bottom half may seem to be a frame ahead of the top. This can happen when the vertical scan of the monitor passes the place where you're drawing. This problem can be solved by starting the on-screen part of the drawing as the tick count changes, or, on a II, synchronize with the appropriate slot VBL interrupt. The only problems caused by doing the animation in your main event loop are ones of speed. If the animation seems jerky, you're not getting enough time. Try it with fewer applications running, or fewer INITs, or fewer Think C debuggers. If the speed is uneven, you should slow down and use the tick count to pace it. (You should pace the motion in any case, so that it doesn't vary from one machine to another.) --Tom Lippincott lippin@math.berkeley.edu "The poetry of motion! The *real* way to travel! The *only* way to travel! Here today -- in next week tomorrow! Villages skipped, towns and cities jumped -- always somebody else's horizons!" --Kenneth Grahame _The Wind in the Willows_