home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / alt / sys / amiga / demos / 1549 < prev    next >
Encoding:
Text File  |  1992-11-11  |  1.7 KB  |  56 lines

  1. Newsgroups: alt.sys.amiga.demos
  2. Path: sparky!uunet!lysator.liu.se!marvil
  3. From: marvil@lysator.liu.se (Martin Vilcans)
  4. Subject: Re: Writing a StarField. Which method is best?
  5. Message-ID: <1947@lysator.liu.se>
  6. Sender: news@lysator.liu.se
  7. Nntp-Posting-Host: robin.lysator.liu.se
  8. Organization: Lysator Academic Computer Society, Linkoping University, Sweden
  9. References: <1992Nov7.104910.60476@cc.usu.edu>
  10. Date: Wed, 11 Nov 1992 19:25:57 GMT
  11. Lines: 43
  12.  
  13. slmt9@cc.usu.edu (Joshua Dinerstein) writes:
  14.  
  15.  
  16. >    In this one I would like to add a star field. But I got to thinking
  17. >about it and I am not sure what method is the best/fastest. Is it fastest to
  18. >try to use and reuse Sprites to put the stars up. Or is just simple drawing the
  19. >best?
  20.  
  21. Using sprites is the fastest and easiest way to do it.
  22. For example, make a sprite which goes like this:
  23.  
  24. sprite0:
  25.  dc.w $30aa,$3100      ;start at y-pos $30
  26.  dc.w $8000,$0000      ; first star
  27.  dc.w $32bb,$3300
  28.  dc.w $8000,$0000    ;second star
  29.  dc.w $34cc,$3500
  30.  .
  31.  .
  32.  .
  33.  
  34. (I'm not really sure that the second control word should contain the y
  35. position +1, making a sprite one pixel high, you'll have to check that.)
  36.  
  37. The values aa, bb and cc should be some random byte values (so the stars
  38. start at different x-positions). The code for moving them look like this:
  39.  
  40. movestars:
  41.     lea sprite0(pc),a0
  42.  
  43.     addq.b #a,1(a0)
  44.     addq.b #b,9(a0)
  45.     addq.b #c,17(a0)
  46.     .
  47.     .
  48.     .
  49.  
  50. ...and a, b and c should be some small random values. This way to do it takes
  51. quite much memory, you can of course change the movestars routine to make a
  52. loop and reading the star speeds from a list, but that is slower. Anyway, a
  53. few hundred bytes can be sacrified for the sake of speed.
  54.  
  55. Good luck, hope you can do it, as more american demos would be fun...
  56.