REM 3rd Person Space Ship Control
REM CR 2007
 
 
rem planet name data
data "Cyclon IV", "Epsilon Prime", "Tangenta", "Sobania", "Hoopla VII", "New Vegas", "Madchester"
 
rem setup screen
cls
hide mouse
sync on
randomize timer()
 
rem set up camera
position camera 0,0,-500
set camera range 1,20000000
autocam off
 
REM make objects and meshes
 
rem make player ship
make object sphere 1,10
make mesh from object 1,1
scale object 1,100,50,100
make object cylinder 2,2.5
scale object 2,100,100,200
make mesh from object 2,2
delete object 2
 
rem add limb which will be the position of the camera
add limb 1,1,1
offset limb 1,1,0,20,-50
hide limb 1,1
 
rem add wings to ship
add limb 1,2,2
add limb 1,3,2
rotate limb 1,2,0,90,90
rotate limb 1,3,0,90,90
offset limb 1,2,5,0,0
offset limb 1,3,-5,0,0
 
rem make star box
make object cube 2,-1000000
set object 2,1,1,1,1,0,1,0
 
rem make planets
num=7
dim planet_name$(num)
dim planet(num)
 
for a=1001 to 1000+num
	read planet_name$(a-1000)
	make object sphere a,rnd(400)+100
	x#=rnd(10000)
	y#=rnd(10000)
	z#=rnd(10000)
	position object a,x#,y#,z#
next a
 
rem dim the lights
set ambient light 50
 
rem draw stars
create bitmap 1,256,256
set current bitmap 1
cls
ink rgb(255,255,255),0
for a=1 to 50
	dot rnd(256),rnd(256)
next a
get image 2,0,0,256,256
texture object 2,2
scale object texture 2,2,2 
 
rem draw planets
cls
for b=1 to num
	planet_colour=rnd(2)
	for a=1 to 50000
		select planet_colour
			case 0
				ink rgb(rnd(100)+50,rnd(100)+155,rnd(100)+155),0
			endcase
			case 1
				ink rgb(rnd(100)+155,rnd(100)+50,rnd(100)+155),0
			endcase
			case 2
				ink rgb(rnd(100)+155,rnd(100)+75,rnd(100)+50),0
			endcase
		endselect
		dot rnd(256),rnd(256)
	next a
	blur bitmap 1,6
	get image 1000+b,0,0,256,256
	texture object 1000+b,1000+b
	set object 1000+b,1,1,1
next b
 
 
rem draw ship wings
cls rgb(255,255,255)
get image 100,0,0,1,1
 
rem main loop
do
 
	rem ship movement controls
	if spacekey()=1 and thrust<50
		inc thrust,5
	endif
	if leftkey()=1 
		roll object left 1,3
	endif
	if rightkey()=1 
		roll object right 1,3
	endif
	if upkey()=1 
		pitch object down 1,2
	endif
	if downkey()=1
		pitch object up 1,2
	endif
 
	rem decelerate ship
	if thrust>0 then dec thrust
	move object 1,thrust
 
	rem position star box
	position object 2,object position x(1),object position y(1),object position z(1)
 
	rem position and orientate camera 
	set camera to object orientation 1
	position camera limb position x(1,1), limb position y(1,1), limb position z(1,1)
 
	rem rotate planets
	for a=1001 to 1000+num
		turn object left a,0.1
	next a
 
	rem draw ship texture
	set current bitmap 1
	cls rgb(200,200,220)
	for a=2 to thrust+5
		ink rgb(100+a*2,a*2,a*2),0
		circle 156,128,a/3
		circle 100,128,a/3
	next a
	get image 1,0,0,256,256
	texture object 1,1
	texture limb 1,2,100
	texture limb 1,3,100
 
	rem draw planet lables
	set current bitmap 0
	for a=1 to num
		ink rgb(255,255,255),0
		if object in screen(a+1000)=1 then text object screen x(a+1000),object screen y(a+1000), planet_name$(a)
	next a
 
	sync
loop