'===========================================================================
' Subject: STARFIELD                          Date: 11-18-95 (04:15)       
'  Author: jackmott@ix.netcom.com             Code: QB, QBasic, PDS        
'  Origin: comp.lang.basic.misc             Packet: EGAVGA.ABC
'===========================================================================
'I wrote the following with QuickBasic 4.5 (the commercial one) if you run this
'with Qbasic that comes with DOS it will go REAL slow, but there is a variable
'you can change that I will comment profusely that will speed it up with a lack
'of quality..also you can just change the screen resolution and stuff if it is
'too slow, I am on a p90 for reference.

'    This program makes a random and very cool starfield, then makes graphs
'various things that resemble black holes and galaxies..makes good screen saver
'type thing, and show it to your math teacher for extra credit...

'I have this written in pascal at the highschool if anyone wants it in that let
'me know, its an easy conversion.



SCREEN 12           'Check help files for other settings, this is good hi-res
RANDOMIZE TIMER

radians = 1.57079632679#        'constant for 90 degrees in radians
   


DO      'Main body
		DO                        'Big Stars

				x = INT(RND * 640 + 1)      'This part makes really really
				y = INT(RND * 480 + 1)      'cool looking stars
				COLOR 15
				PSET (x, y)

				COLOR 7
				PSET (x - 1, y)
				PSET (x + 1, y)
				PSET (x, y - 1)
				PSET (x, y + 1)
				COLOR 8
				PSET (x - 2, y)
				PSET (x + 2, y)
				PSET (x, y - 2)
				PSET (x, y + 2)
				i = i + 1
		LOOP UNTIL i = 20     'Big stars - change the value here for more stars
	   
'The parts below make normal single pixel stars       

COLOR 8
i = 0
		DO                     'Dim little stars
				x = INT(RND * 640 + 1)
				y = INT(RND * 480 + 1)
				PSET (x, y)
				i = i + 1
		LOOP UNTIL i = 180     'Dim little stars

COLOR 15
i = 0
		DO                     'Bright litte stars
				x = INT(RND * 640 + 1)
				y = INT(RND * 480 + 1)
				PSET (x, y)
				i = i + 1
		LOOP UNTIL i = 90      'Bright little stars

COLOR 7
i = 0
		DO                      'medium little stars
				x = INT(RND * 640 + 1)
				y = INT(RND * 480 + 1)
				PSET (x, y)
				i = i + 1
		LOOP UNTIL i = 150       'medium little stars





theta = 1

c = INT(RND * 15 + 1)  'color scheme, picks a random NON-black color
if c = 0 then c = 4
color c

hole = INT(RND * 16 + 1)    'Random value to select type of graph
DO              'Black hole main loop

		

				r = 1.01 ^ theta                    'black hole main formula

			   
SELECT CASE hole      'Variations of the graph
		CASE 1
				y = (SIN(theta)) * r            'Convert polar to cartesian y
				x = (SIN(radians - theta)) * r  'Convert polar to cartesian x
		x = x + theta
		y = y + 240
		CASE 2
				y = (SIN(theta)) * r            'Convert polar to cartesian y
				x = (SIN(radians - theta)) * r  'Convert polar to cartesian x
		x = x - theta + 640
		y = y + 240
	   
		CASE 3
				y = (SIN(theta)) * r            'Convert polar to cartesian y
				x = (SIN(radians - theta)) * r  'Convert polar to cartesian x
		x = x - theta + 640
		y = y - theta + 480

		CASE 4
				y = (SIN(theta)) * r            'Convert polar to cartesian y
				x = (SIN(radians - theta)) * r  'Convert polar to cartesian x
		x = x + theta
		y = y + theta

		CASE 5, 14
	  
				y = (COS(theta)) * r            'Convert polar to cartesian y
				x = (SIN(90 - theta)) * r        'Convert polar to cartesian x
		x = x + 320
		y = y + 240
	   
		CASE 15, 16
				y = (SIN(theta)) * r            'Convert polar to cartesian y
				x = (SIN(radians - theta)) * r  'Convert polar to cartesian x
		
		x = x + 320
		y = y + 240
		
		CASE 6
				y = (SIN(theta)) * r            'Convert polar to cartesian y
				x = (SIN(radians - theta)) * r  'Convert polar to cartesian x
		x = x * theta / 85 + 320
		y = y + theta
		CASE 7
				y = (SIN(theta)) * r            'Convert polar to cartesian y
				x = (SIN(radians - theta)) * r  'Convert polar to cartesian x
		x = x * theta / 85 + 320
		y = y - theta + 480

		CASE 8
				y = (SIN(theta)) * r            'Convert polar to cartesian y
				x = (SIN(radians - theta)) * r  'Convert polar to cartesian x
		x = x + theta
		y = y * theta / 100 + 240

		CASE 9
				y = (SIN(theta)) * r            'Convert polar to cartesian y
				x = (SIN(radians - theta)) * r  'Convert polar to cartesian x
		x = x - theta + 640
		y = y * theta / 100 + 240

		CASE 10
				y = (SIN(theta)) * r            'Convert polar to cartesian y
				x = (SIN(radians - theta)) * r  'Convert polar to cartesian x
		x = x + theta / r + 320
		y = y + theta

		CASE 11
				y = (SIN(theta)) * r            'Convert polar to cartesian y
				x = (SIN(radians - theta)) * r  'Convert polar to cartesian x
		x = x + theta / r + 320
		y = y - theta + 480

		CASE 12
				y = (SIN(theta)) * r            'Convert polar to cartesian y
				x = (SIN(radians - theta)) * r  'Convert polar to cartesian x
		x = x + theta
		y = y + theta / r + 240

		CASE 13
				y = (SIN(theta)) * r            'Convert polar to cartesian y
				x = (SIN(radians - theta)) * r  'Convert polar to cartesian x
		x = x - theta + 640
		y = y + theta / r + 240

END SELECT


				PSET (x, y)                             'Place the dots
				theta = theta + .01  'Make this bigger for more speed!!!!!!!

				breakout$ = INKEY$

		LOOP UNTIL theta > 750 OR breakout$ <> ""

		i = 0
		CLS

		IF breakout$ <> "" THEN END
LOOP                    'Main body
