Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!ncar!news.miami.edu!umiami!dweisman From: dweisman@umiami.ir.miami.edu (Ordinary Man) Newsgroups: comp.sys.mac.programmer Subject: Re: Animation Message-ID: <1991Feb7.233344.7781@umiami.ir.miami.edu> Date: 8 Feb 91 04:33:44 GMT References: <9102030634.AA09598@enuxha.eas.asu.edu> <1991Feb7.093610.12594@ecmwf.co.uk> Organization: Univ of Miami IR Lines: 45 In article <1991Feb7.093610.12594@ecmwf.co.uk>, mab@ecmwf.co.uk (Baudoin Raoult) writes: > In article <9102030634.AA09598@enuxha.eas.asu.edu>, trotter@ENUXHA.EAS.ASU.EDU (Russell T. Trotter) writes: >> 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? >> Thanks to all who reply! > > To avoid flickery animation, you must synchronise your CopyBits with the video spot. > The simplest way is to use TickCount, as the tick counter is updated every 60th of > second, each time the video spot starts to update new screen. So just write: > > tmp := TickCount; > while tmp=Tickcount do { nothing } ; > > CopyBits(.....) This is fine except for a minor detail. As it says in IM Vol. I... "...don't rely on the tick count being incremented to a certain value, such as testing whether it has become equal to its old value plus 1; check for 'greater than or equal to' (since an interrupt task may keep control for more than one tick)." So instead say: tmp:=TickCount; repeat until TickCount>=(tmp+1); CopyBits..... ==Dan -- /-------------------------------------------------------------------------\ | Dan Weisman - University of Miami - Florida | || || || || | |--------------------------------------------------| || || ||\ /|| | | INTERNET -----> dweisman@umiami.IR.Miami.edu | || || || | || | | BITNET -----> dweisman@umiami | ||||||| || | || | |-------------------------------------------------------------------------| | "...bows it's head and prays to the mother of all machines." | \_________________________________________________________________________/