Greetings!
Well...I posted this again because I haven't found a way to align my plane to the matrix (or to the ground...). I put the code here 'cause there's no better way to see than see it for yourself, so here's the code.
Media needed (just for knowing what the files in the code are, push the Code button):
F-16-h2.3ds = a 3D model for the F-16..can use any you want
F-16-h-wnd.3ds = The canopy of the plane...just for using ghost object
Ctower.3ds = a control tower
Ctower-wnd.3ds = the glasses & windows of the control tower
Cockpit.3ds = the 3D test cockpit made by Shiny :)
AMRAAM2.3ds = just a missile :)
Skysphere = the name says it all
Smoke.bmp = just a smoke texture
Dirt.bmp = a dirt texture
sky2.bmp = texture for the skysphere
textures2.bmp = a 512x512 texture, split in a 3x3 grid, used for texturing the matrix with the airbase
tree1.bmp = a tree BMP. For some reason they don't appear :-S
I splitted the code in a lot of labels....I hope you all understand the structure. BTW I didn't commented it too much...

I hope you all help me...now that i'm showing the code...
Game Code:
remstart
250 - 300 = player missiles
MissileStatus:
0 - In plane
1 - Fired
2 - Moving
3 - Exploding
remend
rem declare "global" variables
PlayerMissile=250
PlayerMaxMissile=300
Smoke=700
SmokeMax=850
dim SmokeOn(150)
dim SmokeTime(150)
dim SmokeType(150)
dim MissileStatus(50)
dim MissileTime(50)
dim MissilePos(50)
dim View(0)
dim CamRot1#(0)
dim MSG$(0)
dim MSGTime(0)
dim SM(0)
gosub Init
gosub Load_Resources
gosub Set_Camera
gosub Make_Scenery
gosub Make_Player
gosub Finish_Load
do
gosub Player_Coords
gosub Player_Controls
gosub Player_Update
rem gosub Player_UpdateMissiles
gosub Camera_Controls
gosub Camera_Handle_Views
gosub Scenery_Update
gosub Update_Cockpit
gosub MovePlayerMissiles
gosub UpdateSmoke
gosub Handle_Messages
gosub Info_FPS
gosub Info_Altitude
gosub Info_Misc
sync
loop
`---------
`chase cam
`---------
function chase_cam(id)
` camera controls
` get drone pos.
dis=400
pitch object down 1,8
move object 1,0-dis
position object 150, object position x(1),object position y(1),object position z(1)
move object 1,dis
pitch object up 1,8
if object position y(150)<get ground height(1,object position x(150),object position z(150))
position object 150,object position x(150),get ground height(1,object position x(150),object position z(2))+1,object position z(150)
endif
` move camera
position camera object position x(150),object position y(150), object position z(150)
set camera to object orientation 1
endfunction
`---------
`chase cam
`---------
function chase_cam2(id)
`work out the angle of the object being chased
rem yAng#=curveangle(object angle y(id),yAng#,10)
`grab the objects current position
xPos#=object position x(id)
yPos#=object position y(id)
zPos#=object position z(id)
`other variables
camDist=400
camHeight=8
`work out new position
xCamPos#=newxvalue(xPos#,yAng#,camDist)
zCamPos#=newzvalue(zPos#,yAng#,camDist)
xCamPos#=curvevalue(xCamPos#,object position x(id),8)
yCamPos#=curvevalue(yCamPos#,object position y(id),8)
zCamPos#=curvevalue(zCamPos#,object position z(id),8)
yCamPos#=object position y(id)+camheight
`update camera position
position camera xCamPos#,yCamPos#,zCamPos#
point camera xPos#,yPos#+camheight,zPos#
move camera 0+camDist
point camera xPos#,yPos#,zPos#
endfunction
`---------
`chase cam
`---------
function chase_cam3(id)
`work out the angle of the object being chased
yAng#=curveangle(wrapvalue(camera angle y()+6),camera angle y(),10)
`grab the objects current position
xPos#=object position x(id)
yPos#=object position y(id)
zPos#=object position z(id)
`other variables
camDist=400
camHeight=2
`work out new position
xCamPos#=newxvalue(xPos#,yAng#,camDist)
zCamPos#=newzvalue(zPos#,yAng#,camDist)
xCamPos#=curvevalue(xCamPos#,object position x(id),8)
yCamPos#=curvevalue(yCamPos#,object position y(id),8)
zCamPos#=curvevalue(zCamPos#,object position z(id),8)
yCamPos#=object position y(id)+camheight
`update camera position
position camera xCamPos#,yCamPos#,zCamPos#
point camera xPos#,yPos#+camheight,zPos#
move camera 0+camDist
point camera xPos#,yPos#,zPos#
endfunction
Function Message(Msgtext$,Time)
SM(0)=1
Msg$(0)=Msgtext$
MSGTime(0)=Time
endfunction
Init:
rem set initial graphics mode and variables
ResX=800:ResY=600
set display mode ResX,ResY,16
rem set window on
rem set window title "F-16 Gold Wings"
rem set window position ResX/3,ResY/3
rem restore window
always active on
autocam off
set mipmap mode 1
hide mouse
sync on
sync rate 0
set camera view 0,0,1,1
return
Load_Resources:
rem load resources
load image "textures2.bmp",1
load image "sky2.bmp",10
load image "smoke.bmp",200
rem load image "cockpit2.bmp",100
return
Set_Camera:
rem set camera values
set camera range 1,64000
return
Make_Scenery:
set ambient light 20
rem set directional light 0,0,-1,-1
rem color light 0,rgb(0,0,0)
rem Create fog and ambience
rem set ambient light 40
if fog available()=1
rem fog on : fog distance 18000 : fog color rgb(150,150,150)
FogColor=rgb(150,150,150)
fog on : fog distance 24000 : fog color FogColor
endif
rem make scenery
make matrix 1,100000,100000,40,40
for a=0 to 999999999999999
if matrix exist(1)=1 then exit
next a
prepare matrix texture 1,1,3,3
set matrix tile 1,5,5,4
set matrix tile 1,6,5,5
set matrix tile 1,7,5,6
set matrix tile 1,5,4,7
set matrix tile 1,6,4,8
set matrix tile 1,7,4,9
set matrix texture 1,1,1
update matrix 1
rem Create spherical sky
load object "skysphere.3ds",100
set object collision off 100
scale object 100,60000,60000,60000
set object 100,1,1,1,1,1,1,1
texture object 100,10
rem scale object texture 100,1,2
rem fade object 100,0
rem backdrop off
rem Small ground of perimitor trees
load image "tree1.bmp",4
make object plain 52,2,4 : make mesh from object 52,52
add limb 52,1,52 : rotate limb 52,1,0,90,0
make mesh from object 52,52 : delete object 52
make object 52,52,0
range=50000
halfrange=range/2
prob=20
for t=1 to prob
rx=0+rnd(50000)
rz=0+rnd(50000)
add limb 52,t,52
offset limb 52,t,rx,0,rz
next t
make mesh from object 52,52 : delete object 52 : make object 52,52,4
scale=20
scale object 52,scale*100,scale*100,scale*100
position object 52,0,scale*2,0
set object 52,1,0,0
rem make control tower
load object "ctower.3ds",20
load object "ctower-wnd.3ds",21
ghost object on 21
set object 21,1,1,0
glue object to limb 21,20,0
scale object 20,125,125,125
position object 20,14780,0,14100
return
Make_Player:
rem load player
load object "f-16-h2.3ds",1
load object "f-16-h-wnd.3ds",2
color object 2,rgb(128,128,128)
rem position object 1,250,10,250
rem load missiles
rem position object 5,200,10,250
SideWind$="Sidewinder.3ds"
AMRAAM$="AMRAAM2.3ds"
SideWind$=AMRAAM$
load object SideWind$,250:scale object 250,80,80,80
load object SideWind$,251:scale object 251,80,80,80
load object AMRAAM$,252:scale object 252,80,80,80
load object AMRAAM$,253:scale object 253,80,80,80
MissilePos(0)=0
MissilePos(1)=1
MissilePos(2)=2
MissilePos(3)=3
rem position object 2,250,get ground height(1,250,250),250
rem ghost object on 1
ghost object on 2
glue object to limb 2,1,0
view(0)=0
make object sphere 150,0.1
scale object 150,0.1,0.1,0.1
scale object 1,3000,3000,3000
load object "cockpit.3ds",30
yrotate object 30,90
fix object pivot 30
rem lock object on 30
rem position object 30,0,-381,316
rem make cockpit
rem sprite 1,0,0,100
rem set sprite 1,0,1
rem position object 1,25000,2,25000
position object 1,15000,2,15000
return
Finish_Load:
if object exist(30)=1 then show object 30
if object exist(1)=1 then hide object 1
if object exist(2)=1 then hide object 2
cx#=4
set camera view 0,0,screen width(),screen height()
if object exist(30)=1 then set camera to object orientation 30
return
Player_Controls:
if leftkey()=1 then fr#=fr#+4
if rightkey()=1 then fr#=fr#-4
if downkey()=1 then fu#=fu#+2
if upkey()=1 then fu#=fu#-2
` hat switch commands
if inkey$()="x" then turn object left 1, 1
if inkey$()="c" then turn object right 1, 1
if fr#>0 then fr#=fr#-1
if fr#<0 then fr#=fr#+1
rem fr2#=curvevalue(fr#,fr2#,10)
if fr#>=12 then fr#=12
if fr#<=-12 then fr#=-12
if fu#>0 then fu#=fu#-0.5
if fu#<0 then fu#=fu#+0.5
if fu#>8 then fu#=8
if fu#<-8 then fu#=-8
roll object left 1,fr#/5
pitch object up 1, fu#/8
if inkey$()="a" then thrust#=thrust#+.50
if thrust#>50 then thrust#=50
if inkey$()="z" then thrust#=thrust#-.10
if thrust#<0 then thrust#=0
return
Player_Update:
speed#=curvevalue(thrust#,speed#,25)
move object 1, speed#
altitude#=playery#-40
remstart
if altitude#>300
`stall
if speed#<12 then position object 1, playerx#, playery#-(15-speed#), playerz#
if speed#<7 then position object 1, playerx#, playery#-(9-speed#),playerz#
set cursor 1,1
print "STALL!"
set cursor 50,1
endif
remend
if playery#<get ground height(1,playerx#,playerz#)+40
playery#=get ground height(1,playerx#,playerz#)+40
position object 1,playerx#,playery#,playerz#
endif
if altutide#>200
enable object zdepth 30
else
disable object zdepth 30
endif
return
Player_UpdateMissiles:
UpdateMissile(250,speed#,playerx#,playery#,playerz#,0)
UpdateMissile(251,speed#,playerx#,playery#,playerz#,1)
return
Player_Coords:
playerx#=object position x(1)
playery#=object position y(1)
playerz#=object position z(1)
playerangx#=object angle x(1)
playerangy#=object angle y(1)
playerangz#=object angle z(1)
return
Update_Cockpit:
rem remstart
rem if altitude# > 300
rem lock object off 30
position object 30,playerx#,playery#,playerz#
set object to object orientation 30,1
pitch object up 30,90
move object 30,-371
pitch object down 30,90
move object 30,350
rem position object 30,0,-381,316
rem else
rem position object 30,0,0,0
rem lock object on 30
rem position object 30,0,-381,316
rem endif
rem remend
return
Camera_Controls:
if inkey$()="1"
Message("Cockpit View",30)
view(0)=0
show object 30
hide object 1:hide object 2
endif
if inkey$()="2"
Message("Cockpit Close-Up View",30)
view(0)=1
show object 30
hide object 1:hide object 2
endif
if inkey$()="3"
Message("Locked Chase View",30)
view(0)=2
hide object 30
show object 1:show object 2
endif
if inkey$()="4"
Message("Free Chase View",30)
view(0)=3
hide object 30
show object 1:show object 2
endif
if inkey$()="5"
Message("Rotating Chase View",30)
view(0)=4
hide object 30
show object 1:show object 2
endif
return
Camera_Handle_Views:
if view(0)=0
position camera playerx#,playery#,playerz#
set camera to object orientation 1
pitch camera up 90
move camera 20
rem move camera 65
pitch camera down 90
move camera 55
rem move camera 45
rem move camera 80
position mouse 320,240
set camera to object orientation 30
cx#=wrapvalue(cx#+mousemovey())
cy#=wrapvalue(cy#+mousemovex())
cz#=wrapvalue(cz#+mousemovez())
cx2#=wrapvalue(object angle x(30)+cx#)
cy2#=wrapvalue(object angle y(30)+cy#)
cz2#=wrapvalue(object angle z(30)+cz#)
xrotate camera cx2#
yrotate camera cy2#
zrotate camera cz2#
cx3#=wrapvalue(camera angle x()-object angle x(30))
cy3#=wrapvalue(camera angle y()-object angle y(30))
cz3#=wrapvalue(camera angle z()-object angle z(30))
rem if cx3#<25 then xrotate camera 25
rem if cx3#>270 then xrotate camera 270
if mouseclick()=2
rem set camera to object orientation 30
cx#=4:cy#=0:cz#=0
cx2#=0:cy2#=0:cz2#=0
position mouse 320,240
endif
endif
if view(0)=1
position camera playerx#,playery#,playerz#
set camera to object orientation 1
pitch camera up 90
move camera 10
rem move camera 65
pitch camera down 90
move camera 110
rem move camera 45
rem move camera 80
endif
if view(0)=2
chase_cam(1)
endif
if view(0)=3
chase_cam2(1)
endif
if view(0)=4
chase_cam3(1)
endif
return
Scenery_Update:
rem backdrop on
color backdrop FogColor
scroll object texture 100,0.0004,0
position object 100,playerx#,0,playerz#
return
Handle_Messages:
if SM(0)=1
center text screen width()/2,5,MSG$(0)
MSGTime(0)=MSGTime(0)-1
if MSGTime(0)<=0
SM(0)=0
MSGTime(0)=0
endif
endif
return
Info_FPS:
set cursor 0,0
print screen fps(),"/32 Max FPS"
set cursor 0,14
print "Cursor keys, A/Z = Speed, X/C = Turning, 1/2/3/4 = Camera views"
return
Info_Altitude:
set cursor 0,54
print "Speed: ",speed#
set cursor 0,68
print "Altitude: ",altitude#
print playerx#,",",playery#,",",playerz#
print "skysphere size: ",object size x(100)
return
Info_Misc:
set cursor 0,26
print "Rot z: ",fr#
set cursor 0,26+(10+4)
print "Rot x: ",fu#
print cx3#,",",cy3#,",",cz3#
return
MovePlayerMissiles:
if inkey$()="g" then FireMissile(250,0)
if inkey$()="h" then FireMissile(251,1)
if inkey$()="j" then FireMissile(252,2)
if inkey$()="k" then FireMissile(253,3)
for Mis=PlayerMissile to PlayerMaxMissile
if object exist(Mis)=0 then goto Nxt
T=Mis-PlayerMissile
if MissileStatus(T)=0 then UpdateMissile(Mis,speed#,playerx#,playery#,playerz#,MissilePos(T)) : goto Nxt
if MissileStatus(T)=1
MissileTime(T)=MissileTime(T)+1
position object Mis*10,object position x(Mis),object position y(Mis),object position z(Mis)
set object to object orientation Mis*10,Mis
move object Mis,70
misx#=object position x(Mis*10)
misy#=object position y(Mis*10)
misz#=object position z(Mis*10)
Smooke(Smoke,SmokeMax,misx#,misy#,misz#,50.0,30,0)
move object Mis*10,70
move object Mis*10,-50
position light Mis,object position x(Mis*10),object position y(Mis*10),object position z(Mis*10)
position light Mis*10,object position x(Mis*10),object position y(Mis*10),object position z(Mis*10)
if MissileTime(t)>100
delete object Mis
delete object Mis*10
delete light Mis
delete light Mis*10
goto Nxt
endif
endif
Nxt:
next mis
return
UpdateSmoke:
for Smk=Smoke to SmokeMax
if object exist(smk)=0 then goto nxt2
if object exist(smk)=1
if SmokeOn(smk-smoke)=1
if SmokeType(smk-smoke)=1 then position object smk,object position x(smk),object position y(smk)+10,object position z(smk)
set object to camera orientation smk
SmokeTime(smk-smoke)=SmokeTime(smk-smoke)-1
if SmokeTime(smk-smoke)<=0
delete object smk
SmokeTime(smk-smoke)=0
SmokeOn(smk-smoke)=0
endif
endif
endif
nxt2:
next Smk
return
function Smooke(Smoke,SmokeMax,x#,y#,z#,size#,Tm,Typ)
for y2=smoke to smokemax
if object exist(y2)=0 then exit
next y2
make object plain y2,size#,size#
set object to camera orientation y2
ghost object on y2
texture object y2,200
position object y2,x#,y#,z#
SmokeOn(y2-smoke)=1
SmokeTime(y2-smoke)=Tm
SmokeType(y2-smoke)=Typ
endfunction
function UpdateMissile(Missile,spd#,thex#,they#,thez#,Pos)
position object Missile,thex#,they#,thez#
set object to object orientation Missile,1
move object Missile,spd#
remstart
/\
/||\
1 3 5 7 / \ 6 4 2 0
/-----/ \-----\
|| | | | | ||
\-----\ /\ /-----/
\ || /
\||/
\/
||
||
remend
if Pos = 0
turn object right Missile,90
move object Missile,145
turn object left Missile,90
turn object right Missile,180
move object Missile,70
turn object left Missile,180
endif
if Pos = 1
turn object left Missile,90
move object Missile,145
turn object right Missile,90
turn object right Missile,180
move object Missile,70
turn object left Missile,180
endif
if Pos = 2
turn object right Missile,90
move object Missile,120
turn object left Missile,90
turn object right Missile,180
move object Missile,70
turn object left Missile,180
pitch object down Missile,90
move object Missile,10
pitch object up Missile,90
endif
if Pos = 3
turn object left Missile,90
move object Missile,120
turn object right Missile,90
turn object right Missile,180
move object Missile,70
turn object left Missile,180
pitch object down Missile,90
move object Missile,10
pitch object up Missile,90
endif
endfunction
function FireMissile(Miss,Miss2)
if MissileStatus(Miss2)<>0 then exitfunction
make object sphere Miss*10,10
hide object Miss*10
make light Miss
set light range Miss,250
color light Miss,rgb(255,178,67)
make light Miss*10
set light range Miss*10,250
color light Miss*10,rgb(255,178,67)
MissileStatus(Miss2)=1
endfunction
***********************************************************
Total Lines: 753
I hope that now someone help me and my problem gets resolved. Without that the plane can't land

....and we all know that ALL the planes must descend and land correctly (unless it's got a motor failure, low fuel or something like that...

)
Thanks in advance
Current Projects: F-16 Gold Wings
