Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
starfield challenge
#21
:o awesome!!! i love it

its even kooler because the stars start dark and get slightly brighter as they get closer.

major credit relsoft
This is the end of everything, you are the end of everything." -Slipknot - Everything Ends

"GOD HATES US ALL!!" -Slayer - God Hates Us All
Reply
#22
Code:
'Through the ring of saturn...
'JKC 2003


TYPE star
  x AS INTEGER
  y AS INTEGER
  z AS INTEGER
END TYPE

starnum% = 300
xoff% = 600
yoff% = 300
depth% = 300

DIM astar(0 TO starnum%) AS star
DIM oldstar(0 TO starnum%) AS star

RANDOMIZE TIMER

FOR i = 0 TO starnum%
  astar(i).x = RND * 640
  astar(i).y = RND * 480
  astar(i).z = RND * depth%  
NEXT i

SCREEN 11

CLS

DO
FOR i = 0 TO starnum%
  
IF astar(i).z < 1 THEN astar(i).z = depth% ELSE astar(i).z = astar(i).z - 1   '*put far when near

'* The offsets, scale, and other parameters...some of these are redundant, but allow you to control how it looks.
'* For example, try making the 10's into 100...or make one 200 and the other 2...
   zscale = astar(i).z / depth%    'scales 0 to 1
   scalex% = astar(i).x / (1 + (10 * zscale))
   scaley% = astar(i).y / (1 + (10 * zscale))
   xoffset = xoff% * zscale
   yoffset = yoff% * zscale
   x = xoffset + scalex%
   y = yoffset + scaley%
   rad% = 5 / (1 + astar(i).z / 20)
  
   FOR p% = 0 TO oldstar(i).z                       'to erase last one
     CIRCLE (oldstar(i).x, oldstar(i).y), p%, 0
   NEXT p%
  
   FOR p% = 0 TO rad%                               'to draw next one
     CIRCLE (x, y), p%
   NEXT p%
  
   oldstar(i).x = x
   oldstar(i).y = y
   oldstar(i).z = rad%

NEXT i

LOOP UNTIL INKEY$ <> ""

END

OK...I didn't look at anyone elses method. I've never used type before...man...really useful for keeping track of a bunch of objects!!!

EDIT...here's a variation...think slinky tunnel...
Code:
'Through the ring of saturn...
'JKC 2003

DEFINT I
DEFINT T
TYPE star
  x AS INTEGER
  y AS INTEGER
  z AS INTEGER
END TYPE

starnum% = 300
xoff% = 575
yoff% = 300
depth% = 300

DIM astar(0 TO starnum% + 40) AS star
DIM oldstar(0 TO starnum% + 40) AS star

RANDOMIZE TIMER

DO WHILE i < starnum%
FOR t = 0 TO 640 STEP 40
  i = i + 1
  IF i > starnum% THEN EXIT DO
  astar(i).x = t
  astar(i).y = 0
  astar(i).z = i
NEXT t
FOR t = 0 TO 480 STEP 40
  i = i + 1
  IF i > starnum% THEN EXIT DO
  astar(i).x = 640
  astar(i).y = t
  astar(i).z = i
NEXT t
FOR t = 640 TO 0 STEP -40
  i = i + 1
  IF i > starnum% THEN EXIT DO
  astar(i).x = t
  astar(i).y = 480
  astar(i).z = i
NEXT t
FOR t = 480 TO 0 STEP -40
  i = i + 1
  IF i > starnum% THEN EXIT DO
  astar(i).x = 0
  astar(i).y = t
  astar(i).z = i
NEXT t
LOOP

FOR i = starnum% TO starnum% + 40
  astar(i).x = RND * 640
  astar(i).y = RND * 480
  astar(i).z = RND * depth%
NEXT i
starnum% = starnum% + 40

SCREEN 11

DO
FOR i = 0 TO starnum%
   IF astar(i).z < 1 THEN astar(i).z = depth% ELSE astar(i).z = astar(i).z - 1
   zscale = astar(i).z / depth%    'scales 0 to 1
   scalex% = astar(i).x / (1 + (5 * zscale))
   scaley% = astar(i).y / (1 + (5 * zscale))
   xoffset = xoff% * zscale
   yoffset = yoff% * zscale
   x = xoffset + scalex%
   y = yoffset + scaley%
   rad% = 5 / (1 + astar(i).z / 20)
  
   FOR p% = 0 TO oldstar(i).z
     CIRCLE (oldstar(i).x, oldstar(i).y), p%, 0
   NEXT p%
   FOR p% = 0 TO rad%
     CIRCLE (x, y), p%
   NEXT p%
  
   oldstar(i).x = x
   oldstar(i).y = y
   oldstar(i).z = rad%

NEXT i

LOOP UNTIL INKEY$ <> ""

END

And one more....

Code:
'Through the ring of saturn...
'JKC 2003


TYPE star
  x AS INTEGER
  y AS INTEGER
  z AS INTEGER
END TYPE

starnum% = 103
xoff% = 600
yoff% = 300
depth% = 300

DIM astar(0 TO starnum%) AS star
DIM oldstar(0 TO starnum%) AS star

RANDOMIZE TIMER

FOR i = 1 TO 103
  READ z, y, x
  astar(i).x = x * 20
  astar(i).y = y * 60
  astar(i).z = z * 5  
NEXT i

SCREEN 11

DO
FOR i = 1 TO starnum%
   IF astar(i).z < 1 THEN astar(i).z = depth% ELSE astar(i).z = astar(i).z - 1
   zscale = astar(i).z / depth%    'scales 0 to 1
   scalex% = astar(i).x / (1 + (10 * zscale))
   scaley% = astar(i).y / (1 + (10 * zscale))
   xoffset = xoff% * zscale
   yoffset = yoff% * zscale
   x = xoffset + scalex%
   y = yoffset + scaley%
   rad% = 5 / (1 + astar(i).z / 20)
  
   FOR p% = 0 TO oldstar(i).z
     CIRCLE (oldstar(i).x, oldstar(i).y), p%, 0
   NEXT p%
   FOR p% = 0 TO rad%
     CIRCLE (x, y), p%
   NEXT p%
  
   oldstar(i).x = x
   oldstar(i).y = y
   oldstar(i).z = rad%

NEXT i

LOOP UNTIL INKEY$ <> ""

END
'm
DATA 2,7,1,2,6,1,2,5,1,2,4,1,2,3,1,3,2,1,4,3,1,4,4,1,4,5,1,5,2,1
DATA 6,3,1,6,4,1,6,5,1,6,6,1,6,7,1
'a
DATA 8,7,5,8,6,5,8,5,5,8,4,5,8,3,5,9,2,5,10,2,5,9,5,5,10,5,5,11,7,5,11,6,5,11,5,5,11,4,5,11,3,5
'n
DATA 13,7,9,13,6,9,13,5,9,13,4,9,13,3,9,14,2,9,15,2,9,16,7,9,16,6,9,16,5,9,16,4,9,16,3,9
'g
DATA 18,6,13,18,5,13,18,4,13,18,3,13,19,2,13,19,7,13,20,7,13,20,2,13,21,6,13,21,3,13,20,5,13,21,5,13
'o
DATA 23,6,17,23,5,17,23,4,17,23,3,17,24,2,17,24,7,17,25,7,17,25,2,17,26,6,17,26,3,17,26,5,17,26,4,17
'extra
DATA 29,5,24,30,5,23,31,5,22,32,5,21,33,5,20,34,5,19,35,5,18,34,5,17,33,5,16,32
DATA 5,15,31,5,14,30,5,13,29,5,12,36,5,17,37,5,16,38,5,15,39,5,14,40,5,13,41,5,12,42,5,11,43,5,10,44,5,9
DATA 45,5,8,46,5,7,47,5,6,48,5,5,49,5,4,50,5,3,51,5,2,52,5,1,53,5,1,54,5,1,55,5,1,56,5,1,57,5,1,58,5,1,59,5,1,60,5,1,61,5,1,62,5,1,63,5,1
Reply
#23
Whoa... that's really cool and unique!
am an asshole. Get used to it.
Reply
#24
Me stealing all these for QBNZ, anyone mind? *pant, pant*
Reply
#25
Go ahead. ;*)
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#26
It's in Barok's post of other people's starfields...if you haven't seen it...take a look. You won't be sorry.

User controlable
It does anti-aliasing among other things....
and pallet switching...
and has a very cool escape sequence...

Lots to learn from this code. It's the last one in Barok's long post.
Reply
#27
Yeah, I liked that one too. Except for the errors when using over 2000 stars...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)