home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!ukma!cs.widener.edu!eff!world!howlett
- From: howlett@world.std.com (Joseph S Howlett)
- Subject: Re: Arcade-style animation...
- Message-ID: <C1JJIK.LMr@world.std.com>
- Organization: The World Public Access UNIX, Brookline, MA
- References: <1993Jan25.094256.12845@rulway.LeidenUniv.nl> <34994@goofy.apple.COM> <1k6pol$bvn@agate.berkeley.edu>
- Date: Thu, 28 Jan 1993 01:44:43 GMT
- Lines: 55
-
- >Do people think it's worth bothering with synchronizing with the VBL
- >when drawing sprites? I'm writing a physics simulator with some
-
- What I've done (and it seems to work beautifully so far) is to assume
- that there will be a maximum dx and dy by which any sprite will
- move in one frame. I have custom assembly blitting and masking
- routines which depend on the fact that I know in advance I am
- copying 32x32 or 16x16 rectangles from my sprite buffers to the screen.
-
- My animation goes like this:
-
- Copy bg to offscreen
- Copy bg to screen
-
- For each frame of animation:
- Mask all sprites at current position to offscreen
- Blit rectangles for each sprite from offscreen to screen.
- The important thing here is that the rectangles are the
- bounding rects of the sprites PLUS the maximum dx or dy
- in each direction. Thus, in one blit I simultaneously
- erase the old sprite and blit the new one.
- Blit bounding rectangles of each sprite from bg to offscreen,
- thus erasing all the sprites.
- Do collision detection, etc., and update sprite positions.
-
- The routines which form the core of my graphics stuff are:
-
- Blit 4x4,16x16,and 32x32 rects from source to dest pixmap
- (these are for erasing sprites by copying bg to offscreen)
-
- Blit 12x12,24x24,and 40x40 rects from src to dest pixmap
- (these are for copying offscreen to screen)
-
- Mask 4x4,16x16,and 32x32 icons to dest pixmap
- (these are for drawing sprites to the screen)
-
- Collision detection between each combination of 4x4,16x16,and 32x32
- sprites.
-
- The blitting is basically done with unrolled loops of movem.l
- instructions.
-
- The masking is done with masks which have been converted to 8 bits
- wide.
-
- I tried VBL synching, but found that it really didn't make any
- visual difference since I'm erasing & drawing the new sprites in
- one blit, so I abandoned it. The VBL synching might also make your
- program possibly run at different speeds on machines with monitors
- which have different refresh rates, which is not good.
-
- Hope this helps,
- Scott Howlett
-
- (insert witty .sig here)
-