home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sys / mac / programm / 18783 < prev    next >
Encoding:
Internet Message Format  |  1992-11-22  |  3.8 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!rutgers!cmcl2!adm!afterlife!mssmith
  2. From: mssmith@afterlife.ncsc.mil (M. Scott Smith)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Animating sprites ?: restoring bkground
  5. Message-ID: <1992Nov22.185648.1305@afterlife.ncsc.mil>
  6. Date: 22 Nov 92 18:56:48 GMT
  7. Organization: The Great Beyond
  8. Lines: 71
  9.  
  10. Hello..
  11.  
  12.    I know I've asked lots of questions about animating on the Mac in the
  13. past, but I'm not out of questions yet.  :)
  14.  
  15.    I still am struggling with ways to "restore" the background behind a
  16. sprite once a sprite moves on.
  17.  
  18.    For example, in games like Lemmings, I'll call each of the Lemmings
  19. a "sprite" (for lack of better word).  Now, say a Lemming is walking past
  20. a tree which is in the background.  As the Lemming walks past it, he doesn't
  21. leave a trail of black behind; the tree is "restored".
  22.  
  23.    I know how to make parts of the tree appear through the Lemming, by using
  24. masking or transparent copy modes, etc.
  25.  
  26.    But now I'm trying to deal with the issue of restoring the background of
  27. an area that a sprite was on top of, once the sprite has moved on.
  28.  
  29. These are some ways I've considered:
  30.  
  31. - If I have a little man walking to the right, then I could include draw
  32. a black border around the man (at least on the left, if walking right) so
  33. that he would automatically erase his old position as he moves along.
  34. Hmm.  Actually, I guess this is a separate problem I'm having, which
  35. involves erasing the old position.  I'm still trying to find quick ways to
  36. do that.  But it's related to the background question.  (I've found that
  37. if I include a black border, then I can't take advantage of the transparent
  38. copy mode or other methods of letting the background "seep" through; in
  39. addition, adding that border takes up more bytes, which may or may not
  40. be something worth worrying about.
  41.  
  42. - Do a CopyBits of the rectangular area that will be affected when a sprite
  43. moves into it.  Draw the sprite in the area.  Then slap that rectangle of
  44. the background back on the screen to restore it (and, I guess, erase the
  45. sprite), then keep a copy of the next rectangle that will be affected, etc.
  46. I haven't tried this yet, but it seems this might be slow and possibly
  47. result in flickering.  After all, you're working with rectangles and will
  48. most likely be copying bits that wouldn't need restoring anyway.
  49.  
  50. I guess that last method is the way I have a feeling it might be done.
  51. But it doesn't seem right.
  52.  
  53. Am I missing something pretty obvious with this?  I see the animation in
  54. Lemmings and other games and when a sprite walks past a background, it's
  55. pretty fluid in restoring it.  It looks like "real life", basically.
  56.  
  57. Actually, I have tried something similar to the last method once, and the
  58. results were OK, I guess.  I have a sprite (about the size of a Lemming),
  59. and it walks past a ladder.  Once it passes the ladder, I just re-draw the
  60. sprite of the ladder on the screen, and that looked fine.  But with that
  61. program, I purposely made the sprites make 15-pixel jumps to save time
  62. on animation.  (I wasn't trying to do smooth animation, just trying to
  63. test out an idea for a game.)  And the ladder was less than 15-pixels wide,
  64. so the animated sprite was only over it once in its animation; now that
  65. I'm trying to refine the animation, the sprite would probably be over
  66. it a couple of times before it moved on, and I'm worried the same method
  67. might make flicker.
  68.  
  69. Sorry for my unorganized thoughts.  Any help would be appreciated.  In fact,
  70. I wouldn't be anywhere so far if it wasn't for all the great help I've
  71. received from the net.
  72.  
  73. (I guess to sum it up, I have two main questions: what's the best way of
  74. restoring a background as a sprite animates across it, and also what's the
  75. best way of "erasing" a sprite as it moves.)
  76.  
  77. Thanks in advance!
  78.  
  79. M. Scott Smith
  80.   (mssmith@afterlife.ncsc.mil || umsmith@mcs.drexel.edu)
  81.