home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: alt.sys.amiga.demos
- Path: sparky!uunet!lysator.liu.se!marvil
- From: marvil@lysator.liu.se (Martin Vilcans)
- Subject: Re: Writing a StarField. Which method is best?
- Message-ID: <1947@lysator.liu.se>
- Sender: news@lysator.liu.se
- Nntp-Posting-Host: robin.lysator.liu.se
- Organization: Lysator Academic Computer Society, Linkoping University, Sweden
- References: <1992Nov7.104910.60476@cc.usu.edu>
- Date: Wed, 11 Nov 1992 19:25:57 GMT
- Lines: 43
-
- slmt9@cc.usu.edu (Joshua Dinerstein) writes:
-
-
- > In this one I would like to add a star field. But I got to thinking
- >about it and I am not sure what method is the best/fastest. Is it fastest to
- >try to use and reuse Sprites to put the stars up. Or is just simple drawing the
- >best?
-
- Using sprites is the fastest and easiest way to do it.
- For example, make a sprite which goes like this:
-
- sprite0:
- dc.w $30aa,$3100 ;start at y-pos $30
- dc.w $8000,$0000 ; first star
- dc.w $32bb,$3300
- dc.w $8000,$0000 ;second star
- dc.w $34cc,$3500
- .
- .
- .
-
- (I'm not really sure that the second control word should contain the y
- position +1, making a sprite one pixel high, you'll have to check that.)
-
- The values aa, bb and cc should be some random byte values (so the stars
- start at different x-positions). The code for moving them look like this:
-
- movestars:
- lea sprite0(pc),a0
-
- addq.b #a,1(a0)
- addq.b #b,9(a0)
- addq.b #c,17(a0)
- .
- .
- .
-
- ...and a, b and c should be some small random values. This way to do it takes
- quite much memory, you can of course change the movestars routine to make a
- loop and reading the star speeds from a list, but that is slower. Anyway, a
- few hundred bytes can be sacrified for the sake of speed.
-
- Good luck, hope you can do it, as more american demos would be fun...
-