Starfield...
Author Message
Starfield...

Can someone send me some starfield code/ Instructions on making
one? Or something really simple about it please?

Or look at the code I'M using, and tell me what's wrong? PLEASE
HELP... It's very simple... here it is:

[ PSET.BAS < 1K ]

DIM x(200)           ' I dimensioned these to 200 (even though I have only
DIM y(200)           ' 100 stars because of what I did at the bottom.....
' I first drew the stars out... I don't know why, and
' then I needed the extra 100 to manipulate... you'll
' see ...

FOR i = 1 TO 100
x(i) = INT(RND * 319) + 1       'Find the values and store them.
y(i) = INT(RND * 199) + 1
NEXT i

SCREEN 7, 0, 1, 0

FOR i = 1 TO 100
PSET (x(i), y(i)), 15           'draw out the screen first.. why?
NEXT i                          ' I don't know, it just seems easier.

DO                              ' here's the loop

FOR i = 1 TO 100                ' PSET each "star" one notch over to
x(i) = x(i) + 1                 ' the right.
IF x(i) > 320 THEN x(i) = 1     ' <-- border...
PSET (x(i), y(i)), 15

PCOPY 1, 0                      'page flipping for smoothness.
NEXT i
LOOP

' PLEASE HEEEEEELP ME!!!

Fri, 22 Jan 1999 03:00:00 GMT
Starfield...

i thought I'd just sit down and write one of those star thingymajigs so
here is my efforts:

TYPE star
x AS INTEGER
y AS INTEGER
z AS INTEGER
sx AS INTEGER
sy AS INTEGER
active AS INTEGER
END TYPE

DIM stars(150) AS star

SCREEN 13

FOR i% = 1 TO 150
stars(i%).active = 1
stars(i%).x = INT((190 - -190 + 1) * RND + -190)
stars(i%).y = INT((190 - -190 + 1) * RND + -190)
stars(i%).z = INT((1000 - 15 + 1) * RND + 15)
NEXT i%
DO
FOR ii% = 1 TO 150
IF stars(ii%).active = 1 THEN
PSET (stars(ii%).sx, stars(ii%).sy), 0
stars(ii%).z = stars(ii%).z - 3
stars(ii%).sx = (stars(ii%).x / stars(ii%).z) * 320 + 320 / 2
stars(ii%).sy = (stars(ii%).y / stars(ii%).z) * 200 + 200 / 2
' join the next two lines up, they got trimmed
IF stars(ii%).sx < 320 AND stars(ii%).sx > 0 AND stars(ii%).sy > 0 AND
stars(ii%).sy < 200 THEN PSET (stars(ii%).sx, stars(ii%).sy), 15
IF stars(ii%).z < 12 THEN
stars(ii%).x = INT((190 - -190 + 1) * RND + -190)
stars(ii%).y = INT((190 - -190 + 1) * RND + -190)
stars(ii%).z = INT((1100 - 800 + 1) * RND + 800)
END IF

END IF
NEXT ii%
'WAIT &H3DA, 8
'FOR ii% = 1 TO 100
'        PSET (stars(ii%).sx, stars(ii%).sy), 0
'NEXT ii%

LOOP

Watch out for the trimmed line in there. Tis important.

Cheers

_/   /  ~~~~~~~~~~~~~~~~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~
_/_/_/   Friends: Kari Patterson, Amy Kramer, Crystal B, Anna
_/                 Colleen, Jamie, Rob D, Wildcard, Arnoud
_/              http://www.trenham.demon.co.uk/

Tue, 26 Jan 1999 03:00:00 GMT
Starfield...

Quote:

> i thought I'd just sit down and write one of those star thingymajigs so
> here is my efforts:

> TYPE star
>   x AS INTEGER
>   y AS INTEGER
>   z AS INTEGER
>   sx AS INTEGER
>   sy AS INTEGER
>   active AS INTEGER
> END TYPE

> DIM stars(150) AS star

> SCREEN 13

> FOR i% = 1 TO 150
> stars(i%).active = 1
> stars(i%).x = INT((190 - -190 + 1) * RND + -190)
> stars(i%).y = INT((190 - -190 + 1) * RND + -190)
> stars(i%).z = INT((1000 - 15 + 1) * RND + 15)
> NEXT i%
> DO
> FOR ii% = 1 TO 150
>  IF stars(ii%).active = 1 THEN
>           PSET (stars(ii%).sx, stars(ii%).sy), 0
>   stars(ii%).z = stars(ii%).z - 3
>   stars(ii%).sx = (stars(ii%).x / stars(ii%).z) * 320 + 320 / 2
>   stars(ii%).sy = (stars(ii%).y / stars(ii%).z) * 200 + 200 / 2
> ' join the next two lines up, they got trimmed
>   IF stars(ii%).sx < 320 AND stars(ii%).sx > 0 AND stars(ii%).sy > 0 AND
> stars(ii%).sy < 200 THEN PSET (stars(ii%).sx, stars(ii%).sy), 15
>   IF stars(ii%).z < 12 THEN
>         stars(ii%).x = INT((190 - -190 + 1) * RND + -190)
>         stars(ii%).y = INT((190 - -190 + 1) * RND + -190)
>         stars(ii%).z = INT((1100 - 800 + 1) * RND + 800)
>   END IF

>  END IF
> NEXT ii%
> 'WAIT &H3DA, 8
> 'FOR ii% = 1 TO 100
> '        PSET (stars(ii%).sx, stars(ii%).sy), 0
> 'NEXT ii%

> LOOP

> Watch out for the trimmed line in there. Tis important.

> Cheers

>    _/   /  ~~~~~~~~~~~~~~~~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~
>   _/_/_/   Friends: Kari Patterson, Amy Kramer, Crystal B, Anna
>  _/                 Colleen, Jamie, Rob D, Wildcard, Arnoud
> _/              http://www.trenham.demon.co.uk/

Change the Z velocity from -3 to -10.  It looks cooler.

--
______________________________

Steven Sensarn

______________________________

Thu, 28 Jan 1999 03:00:00 GMT

 Page 1 of 1 [ 3 post ]

Relevant Pages

Powered by phpBB® Forum Software