Ok, I came up with this stripped down version of your code. Press and hold T to target the space station, hit SPACE to randomly place and rotate the Ship. Cursors to roll + pitch.
It's not perfect but should do the job and hopefully makes sense to you.
Stevie
It's not perfect but should do the job and hopefully makes sense to you.
Graphics3D 640, 480, 16, 1 AmbientLight 255, 255, 255 WireFrame True ;ship Global Cobra = CreatePivot();LoadMesh( "Models\CobraMk3.x") Global PitchSpeed# = 1.0 Global RollSpeed# = 1.0 Global Pitch#, Roll# ;camera Global Camera = CreateCamera( Cobra ) ;PositionEntity Camera, 0,0,-50 PositionEntity Camera, 0, 0, 5 ;scene Global Planet = CreateSphere() : ScaleMesh Planet, 10, 10, 10 : EntityColor Planet, 255,0,0 Global Station = CreateSphere( 3 ) : ScaleMesh Station, 2, 2, 2 : PositionEntity Station, 20, 0, 0 : EntityColor Station, 0,0,255 Global Star = CreateCube() : ScaleMesh Star, .25, .25, .25 : HideEntity Star For l = 1 To 100 tmp = CopyEntity( Star , Planet ) RotateEntity tmp, Rand(-90,90 ), 0 , Rand(-180,180 ) PositionEntity tmp, Rand(-200,200 ), Rand(-200,200 ), Rand(-200,200 ) Next ;timing Global FPSWanted = 60 Global Timer = CreateTimer( FPSWanted ) Reset() While Not KeyDown(1) WaitTimer( Timer ) ;reset if 'SPACE' pressed If KeyDown(57) Reset() ;target if 'T' pressed If KeyDown( 20 ) TARGET( Cobra , Station ) Else Roll# = KeyDown( 203) - KeyDown(205) Pitch# = KeyDown( 200 ) - KeyDown(208) EndIf TurnEntity Cobra , Pitch , 0, Roll MoveEntity Cobra, 0, 0, .25 UpdateWorld() RenderWorld() scanner( 320, 420 ) Color 255,0,255 Line 300,240,340,240 Line 320,220,320,260 Flip Wend End ;=================================================== ;=================================================== ;=================================================== Function TARGET( Source , Target ) TFormPoint 0,0,0 , Target, Source RollAngle# = VectorYaw ( TFormedX() , 0 , TFormedY() ) Roll# = Limit( RollAngle , -RollSpeed , RollSpeed ) If Abs( RollAngle ) < 10 Pitch# = Limit( VectorPitch( 0 , TFormedY(), TFormedZ() ) , -PitchSpeed , PitchSpeed ) Else Pitch# = 0 EndIf End Function ;=================================================== ;=================================================== ;=================================================== Function Limit#( q#, lo#, hi# ) If q < lo q = lo If q > hi q = hi Return q End Function ;=================================================== ;=================================================== ;=================================================== Function Reset() PositionEntity Cobra, Rnd( -100,100 ) , Rnd(-100,100 ), Rnd(-100,100 ) RotateEntity Cobra , Rnd(-90,90), 0, Rand(-180,180 ) Delay 250 End Function ;=================================================== ;=================================================== ;=================================================== Function Scanner(scanx,scany) ; Scanner by Timo Souranta ; ;Stations And planets are white because they are greater than 500t ;Scanner size is: Scanx X -115 to Scanx +115 (with a scale of .7) ;Scany Y -37 to Scany +37 Color 255,0,0 Oval scanx-115,scany-37 , 230,74,0 scale# = 0.7 Plot scanx, scany TFormPoint 0,0,0, Station, Cobra x# = TFormedX() * scale y# = TFormedY() * -scale z# = TFormedZ() * scale x1# = x y1# = - z/4 + y/2 y2# = - z/4 If x1 > -200 And x1 < 200 And y1 > -200 And y1 < 200 Then Color 255, 255, 255 If scanx+x1>scanx-115 And scanx+x1<scanx+115 And scany+y1>scany-37 And scany+y1<scany+37 scn=(scany+y1)-(scany+y2) If scn>-30 And scn<30 WritePixel scanx+x1+1, scany+y1, 256*256*255 + 256*255 Line scanx+x1, scany+y1, scanx+x1,scany+y2 EndIf EndIf EndIf End Function
Stevie