Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!uunet!crdgw1!galen.crd.ge.com!leue From: leue@galen.crd.ge.com (Bill Leue) Newsgroups: comp.sys.mac.programmer Subject: Animation Questions Keywords: CopyBits, VBlank Message-ID: <3123@crdgw1.crd.ge.com> Date: 12 Oct 89 13:16:27 GMT Sender: news@crdgw1.crd.ge.com Reply-To: leue@galen.crd.ge.com (Bill Leue) Organization: General Electric Research & Development Lines: 37 I've got a couple of questions regarding animation on the Mac. I know that this material has been discussed before in this group, but I didn't get all of it the first time. Please, no flames if you can restrain yourselves :-). I'm moving some fairly small (app. 100 pixels wide x 20 pixels high) sprites around using what I think is the standard method: copying the background to an offscreen bitmap, drawing the new position of the object in the offscreen bitmap, and CopyBits-ing the whole thing back to the screen. It works pretty well, and eliminates the obnoxious flickering that characterized my first, naive efforts to do animation using XOR drawing. However, there are still two glitches. First, the objects being animated are sometimes "sheared" horizontally, so that they are torn into two pieces which don't quite track each other as the object moves (say) horizontally. I'm tenatively diagnosing this problem as a lack of synchronization with the screen refresh. Am I right? If so, I suspect there's a mechanism to synchronize drawing with vertical blanking. Does anyone have any lore (or posssibly code) they feel like sharing on this subject? Second, I am using "Classic" QuickDraw to perform limited color drawing. I use ForeColor() and BackColor() calls along with a 50% grey pattern fill to get a useful range of colors using dithering. In this way I can get color objects on a color system, but don't have to make special code for monochrome systems. It works fine, except that the objects which are animated using CopyBits only display in black and white. I guess I thought that since I was using the same QD calls to write to the offscreen bitmap that I used to write the "static" portions of the screen, the objects would also show up in color. Wrong! Anyone have an idea what I'm doing wrong? Remember, I am NOT using Color QD at all -- just the 8 colors in normal QD. Thanks! -Bill Leue leue@crd.ge.com