TGC Codebase Backup



3D Starfield by Richard Davey

25th Sep 2003 19:34
Summary

Flying into a 2D starfield. Change stars value for more/less and the slide value for more/less distortion.



Description



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    `	-------------------------------------------------------------------------
`	3D Starfield                                  DarkForge Snippet 27/9/2000
`	-------------------------------------------------------------------------
`	Flying into a 2D starfield. Change stars value for more/less and the 
`	slide value for more/less distortion.

sync rate 0
sync on
hide mouse

randomize timer()

create bitmap 1,640,480

stars=500

dim x#(stars) 
dim y#(stars)

for i = 1 to stars
	x#(i)=rnd(640.0)-320.0
	y#(i)=rnd(480.0)-240.0
next i

sx#=1.03985 : sy#=1.03985
slidex#=320.0 : slidey#=240.0

ink rgb(255,255,255),0

do

	cls 0

	for j=1 to stars
		dot x#(j)+slidex#,y#(j)+slidey#
		x#(j)=x#(j)*sx#
		y#(j)=y#(j)*sy#
		if x#(j) > 640.0 then x#(j)=x#(j)-640.0
		if y#(j) > 480.0 then y#(j)=y#(j)-480.0
		if x#(j) < -640.0 then x#(j)=x#(j)+640.0
		if y#(j) < -480.0 then y#(j)=y#(j)+480.0
	next j

	copy bitmap 1,0
	sync 

loop