Pitch Problems

Blitz3D Forums/Blitz3D Beginners Area/Pitch Problems

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Graphics3D 640,480,32,2
SetBuffer BackBuffer()

TFormFilter 0
Dim side(35) ; used for the display
side(0)=LoadImage("hud_side.bmp")
For i=1 To 35
 side(i)=CopyImage(side(0))
 MidHandle side(i)
 RotateImage(side(i)),i*10
Next
MidHandle side(0)

jet=CreatePivot()
PositionEntity jet,0,3,0
camera=CreateCamera(jet)
CameraRange camera,1,100000
CameraFogMode camera,1
CameraFogRange camera,100,100000
CameraFogColor camera,100,150,170
CameraClsColor camera,100,150,170


ground=CreatePlane()
tex=CreateTexture(1024,1024) ; create a random "landscape"
SetBuffer TextureBuffer(tex)
For i=0 To 5000
 Color Rand(128,255),Rand(128,255),Rand(50,100)
 Rect Rand(-100,1124),Rand(-100,1124),Rand(100),Rand(100),1
Next
SetBuffer BackBuffer()
ScaleTexture tex,10000,10000
EntityTexture ground,tex

speed#=0

EntityType ground,2
EntityType jet,1
Collisions 1,2,2,2



While KeyDown(1)=0

 If KeyDown(200) Then
  speed=speed+1
  If speed >50 Then speed=50
 EndIf
 If KeyDown(208) Then
  speed=speed-.1
  If speed <0 Then speed=0
 EndIf
 button=GetJoy()
 jxs$=JoyX()
 jys$=JoyY()
 jzs$=JoyZ()
 If Instr(jxs$,"e")<>0 Then jxs$="0" ; prevent joystick rounding errors trough exponentional notation...
 If Instr(jys$,"e")<>0 Then jys$="0"
 If Instr(jzs$,"e")<>0 Then jzs$="0"
 jx#=jxs$
 jy#=jys$
 jz#=jzs$

 MoveEntity jet,0,0,speed ; forward
 TranslateEntity jet,0,-1.0,0 ; down by gravity
 rudl#=jy+(-jx) ; check rudders
 rudr#=jy+jx

 
 turnpitch#=-(rudl+rudr)/2.0
 turnroll#=rudl-rudr
 
 TurnEntity jet,turnpitch,0,turnroll

 UpdateWorld()
 RenderWorld()

 ; just some disply stuff
 Color 255,255,255
 Text 0,64,"Atlitude: "+ EntityY(jet)+" m"
 Text 0,80,"Speed: "+speed
 Oval 0,0,50,50,0
 Line 25+Cos(EntityRoll(jet,1))*25,25+Sin(EntityRoll(jet,1))*25,50-(25+Cos(EntityRoll(jet,1))*25),50-(25+Sin(EntityRoll(jet,1))*25)
 Line 25+Cos(EntityRoll(jet,1))*25,25+Sin(EntityRoll(jet,1))*25,50-(25+Cos(EntityRoll(jet,1)+90)*5),50-(25+Sin(EntityRoll(jet,1)+90)*5)
 Line 50-(25+Cos(EntityRoll(jet,1))*25),50-(25+Sin(EntityRoll(jet,1))*25),50-(25+Cos(EntityRoll(jet,1)+90)*5),50-(25+Sin(EntityRoll(jet,1)+90)*5)

50-(25+Sin(EntityPitch(jet,1))*25)
 wside=(18+(((EntityPitch(jet,1)+90.0)*2.0)/10.0))Mod 35
 If wside>35 Then wside=36
 If wside<0 Then wside=0
 DrawImage side(wside),85,25
 Text 120,25,"Pitch: "+EntityPitch(jet,1)
 Flip
Wend


It uses a joystick. First press the Cursor Up key to accellerate. THen pull back the Joystick to lift off. It's using a 50*50 Pixel sideview image of a jetfighter, but as I described, the display stuff don't works as I wanted. The solution I explained in my lates post isn't implemented here.

But of course, like in any 3D game, you need to remain inside a range of -32000 to 32000 to prevent zbuffer inaccuracies (that would result in wobbling geometry)