home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / mac / programm / 22284 < prev    next >
Encoding:
Text File  |  1993-01-27  |  2.4 KB  |  66 lines

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