k
et display mode 800,600,32
set window on
sync on:sync rate 60
SET CAMERA VIEW 0,0,600,600
SET CAMERA ASPECT 1
rem gui interface placment
load image "Data/BMP/maingui.bmp" ,1
sprite 3,600,0,1
load image "Data/Texture/YellowSun.bmp",4
rem player ship
load object "Data/Model/destroyer.x",1
load object "Data/Model/ship.x",3
scale object 3,30,30,30
rotate object 3,90,0,0
position object 3, 20,40,0
`x & y coords and angle of the ship
x#=0
y#=0
angle#=0
cz#=30
rem the sun
make object sphere 2,30
texture object 2,4
position object 2, 20,20,-20
set object light 2,20
make light 1
position light 1,20,20,20
color light 1,247,254,36
set normalization on
rem thrust
`load image "plasma.bmp",3
`make particles 1,3,30,5.0
`component vector magnitude(acceleration of ship)
accel#=0.05
`friction value-must be >1
`the closer it is to 1, the less friction there is
`This is because the main vectors of the ship are devided by this value
friction#=1.035
`turn rate of ship
turnrate#=2
rem ini speed of ship
thrust#=0
`set up a vector type
type vector
x as float
y as float
endtype
`set up the ship's main vector
shipv as vector
shipv.x=0
shipv.y=0
`setup component vector for vector addition
comv as vector
comv.x=0
comv.y=0
rem --- Ok here we go
backdrop off
draw to back
rem trail code
Dim TrailNumber(10, 10)
rem PrepareTrail(4, "Data/BMP/Lens-11.Bmp")
n=500
dim x(n,3)
for i=1 to n
x(i,1)=rnd(600)+1
x(i,2)=rnd(600)+ 1
x(i,3)=rnd(9)+1
next i
do
cls 0
for i=1 to n
x(i,1)=x(i,1)-x(i,3)
if x(i,1)<=1
x(i,1)=600
x(i,2)=rnd(600)
endif
col=x(i,3)*30
ink rgb(col,col,col),1
dot x(i,1),x(i,2)
next i
`rotate the ship
if rightkey()=1 then angle#=angle#-turnrate#
if leftkey()=1 then angle#=angle#+turnrate#
angle#=wrapvalue(angle#)
rotate object 1,90,0,wrapvalue(-1*(angle#+180))
`calculate the component vector (added to the main vector if upkey is pressed)
comv.x=sin(angle#)*accel#
comv.y=cos(angle#)*accel#
`ship movement
if upkey()=1
`add the vectors together to produce a final vector
thrust#=thrust#+0.0005
endif
if downkey()=1
`add the vectors together to produce a final vector
thrust#=thrust#-0.0004
endif
if thrust#>=0.2 then thrust#= 0.2
if thrust#<=-0.1 then thrust#= -0.1
shipv.x=shipv.x+comv.x*thrust#
shipv.y=shipv.y+comv.y*thrust#
if keystate(35)=1
x#=0:y#=0
endif
if keystate(31)=1
thrust#=0
endif
if keystate(209)=1
cz#=cz#+1
endif
if keystate(207)=1
cz#=cz#-1
endif
if cz#<=2 then cz#=2
`calculate friction
shipv.x=shipv.x/friction#
shipv.y=shipv.y/friction#
`reposition the ship
x#=x#+shipv.x
y#=y#+shipv.y
position object 1,x#,y#,0
rem thrust
rem Trail(4, 0, 0, 0, Object Angle X(1), Object Angle Y(1), Object Angle Z(1), 0, 0, 0)
rem position particles 1,newxvalue(x#, angle#,5),newxvalue(y#, angle#,5),z#
remstart
set particle velocity 1,thrust#*100
position particles 1,x#,y#,z#
rotate particles 1,0,0,wrapvalue((0-angle#)-180)
set particle life 1,5
remend
remstart
create bitmap 1,128,128
rem draw your text here
get image 1,0,0,128,128
set current bitmap 0
sprite 1,0,0,1
remend
set cursor 0,0:print screen fps()
set cursor 0,15:print x#
set cursor 0,30:print y#
set cursor 0,45:print angle#
set cursor 0,60:print thrust#
set cursor 0,75:print "press escape key to exit"
set cursor 0,90:print "press H to return to origin"
set cursor 0,105:print "press S to stop"
rem rotate sun
ZROTATE OBJECT 2,OBJECT ANGLE Z(2)+0.1
position camera x#,y#,cz#
rem Point camera at object
point camera x#,y#,z#
sync
loop