Functions list contains prefix of last UDT
issueid=523 08-01-2017 22:27
thinBasic MVPs
Number of reported issues by Michael Hartlef: 42
Functions list contains prefix of last UDT

I noticed something weird. In the Code Browser, the all functions have a prefix with the name of the last UDT which I have defined in the code.

'***********************************************************'*               PowerBoat Championship 2007               *
'*                                                         *
'*          Copyright (c) 2007 by Michael Hartlef          *
'***********************************************************
  




'*---------------------------------------------------------*
'*                         Modules                         *
'*---------------------------------------------------------*


Uses "TBGL" 
Uses "TBDI"  
Uses "UI" 
uses "MAth"
uses "TBass"
uses "File"




'*---------------------------------------------------------*
'*                   User defined types                    *
'*---------------------------------------------------------*


type tSphere
  x as single
  y as single
  z as single
  r as single
end type


'*---------------------------------------------------------*
'*                      Declarations                       *
'*---------------------------------------------------------*


dim desktopX, desktopY, desktopDepth as long
Dim hWnd As Dword   
local i as long
local SpheresNum as long = 4
local Spheres(SpheresNum) as tSphere  
local cX, cY as long
local x, y, z as single
local manX, manY, many2, manZ as single = 200
local xRot as single
local yRot as single
local FrameRate, framecounter as long
local ctime, stime, dtime as single
local dir,tilt, roll as single
local joyX, joyZ as long
local speed as single
dim   vertexcount as long
dim enginespeed, enginevol as long


local dirvec(3) as single
dim   dirx, diry, dirz as single
local floatX, floatY as single
DIM channel AS DWORD
dim sfile as string
dim ret as long
'*---------------------------------------------------------*
'*                         Equates                         *
'*---------------------------------------------------------*


%PowerBoat = 1
%Boje      = 2
%Ocean     = 3


'*---------------------------------------------------------*
'*                     Initialization                      *
'*---------------------------------------------------------*


tbgl_GetDesktopInfo desktopX, desktopY, desktopDepth
framerate = 60
enginespeed = 20000
enginevol = 70


hWnd = TBGL_CreateWindowEx("PowerBoat Championship 2007", 800, 600, 32, %TBGL_WS_CLOSEBOX) 
tbgl_ShowCursor 1
TBGL_ShowWindow 
TBDI_Init(hWnd)


tbgl_LoadBMPFont "Textures\font.bmp", 40   ' We will use bitmap font in 30 lines mode  
tbgl_ClearFrame
tbgl_PrintBMP "Please wait...", 0, 0, %TBGL_ALIGN_CENTER_CENTER
tbgl_PrintBMP "Loading models...", 0, 1, %TBGL_ALIGN_CENTER_CENTER
tbgl_DrawFrame


tbgl_m15InitModelBuffers 3, 6000


'tbgl_m15LoadModel "Models\trackstraight.m15", "Textures\", 1, %Powerboat, %TBGL_NORMAL_SMOOTH
tbgl_m15LoadModel "Models\powerboat.m15", "Textures\", 1, %Powerboat, %TBGL_NORMAL_SMOOTH
tbgl_m15LoadModel "Models\boje.m15", "Textures\", 2, %Boje, %TBGL_NORMAL_SMOOTH  
tbgl_m15LoadModel "Models\ocean.m15", "Textures\", 3, %ocean, %TBGL_NORMAL_SMOOTH  
vertexcount = TBGL_m15GetModelVertexcount( 3)




'for i = 1 to 1024
'   tbgl_m15setvertexy(%ocean,i,0.5)
   'tbgl_PrintBMP "y:" + Format$(tbgl_m15getvertexy(%ocean,i), "#.0000"), 0, i*5
   'tbgl_m15SetVertexParam( %ocean, i, %TBGL_m15y, 2.5)
'next  
   'tbgl_DrawFrame


tbgl_PrintBMP "Set lights...", 0, 3, %TBGL_ALIGN_CENTER_CENTER
tbgl_DrawFrame
tbgl_UseLighting 1
tbgl_UseLightSource %GL_LIGHT0, 1
tbgl_PrintBMP "Done!", 0, 4, %TBGL_ALIGN_CENTER_CENTER
tbgl_DrawFrame


GetAsyncKeyState(-1) ' Resets ESC key status before checking 


'**************** LOAD Sound ******************
IF Sound_Init THEN
  IF TBASS_CHANNELISACTIVE( Channel ) THEN TBASS_CHANNELSTOP( Channel )
  '---In any case better to free the stream
  TBASS_STREAMFREE( Channel )
  '---Now ask which file to load
  sFile = app_sourcepath & "sounds\engine.wav"
  'ShowMessage(sfile)
  if file_exists(sfile) = %TRUE then
    Channel = TBASS_STREAMCREATEFILE( %TBASS_FALSE, sFile, 0, 0, %TBASS_SAMPLE_LOOP OR %TBASS_STREAM_PRESCAN)
    IF Channel = %TBass_FAlse THEN    '---whatever it is, it isn't playable
      ShowMessage( "Can't play the file " & sFile )
    ELSE
'      Ret = TBASS_APPLY3
      ret = TBASS_ChannelSetAttributes(Channel, enginespeed, enginevol, 0)
      ret = TBASS_CHANNELPLAY( Channel, %TBASS_TRUE )
      ' msgbox 0, "CHANNEL value:"+STR$(Ret)
      'Ret = TBASS_SETEAXPRESET( %TBASS_EAX_ENVIRONMENT_CONCERTHALL )
      'Ret = TBASS_SETEAXPRESET( %TBASS_EAX_ENVIRONMENT_BATHROOM )
      ' msgbox 0, "EAX value:"+STR$(Ret)
      'Ret = TBASS_APPLY3D
      ' msgbox 0, "APPLY3D value:"+STR$(Ret)
    END IF
  endif
endif
'**********************************************
stime = gettickcount


manx = 1
many = -0.15
manz = 1


dir = 90
speed = 0


dirvec(1) = 1
dirvec(2) = 0
dirvec(3) = 0


TBGL_PolygonLook %GL_fill


While IsWindow(hWnd) 
  'Calculate FPS
  framecounter = framecounter +1
  ctime = gettickcount
  dtime = ctime - stime
  if dtime >= 1000 then
    FrameRate = framecounter
    framecounter = 0
    stime = ctime
  endif


  for i = 1 to 1024
    floatX = tbgl_m15getVertexParam(%ocean, i, %TBGL_m15X)
    'floatY = tbgl_m15getVertexParam(%ocean, i, %TBGL_m15Y)
    tbgl_m15SetVertexParam( %ocean, i, %TBGL_m15y, sin(gettickcount/1000 + floatx))
  next 




  tbgl_ClearFrame 
  tbgl_Camera 15,7,15,manx,many,manz
  tbgl_PushMatrix
  tbgl_Rotate xRot, 1, 0, 0
  tbgl_Rotate yRot, 0, 1, 0
  TBGL_Scale 20,1,20
  'tbgl_CallList %ocean
  tbgl_m15DrawModel %ocean
  'tbgl_scale 0.05,1,0.05
  tbgl_PopMatrix
  ' This returns x,y,z coordinates under mouse to variables
  tbgl_GetPixelInfo tbgl_MouseGetPosX,tbgl_MouseGetPosY, %TBGL_PINFO_xyz, x, y, z
  
  
  if TBGL_MouseGetLButton then
    manX = x
    manY = y
    manZ = z
  end if
  many2 = getHeight(0,0,0)
  many = getHeight(manx,many,manz)-0.11


  tbgl_PushMatrix  
    tbGL_translate 0,many2,0
    TBGL_SCALE 0.2,0.2,0.2
    TBGL_m15drawmodel %Boje
    'TBGL_SCALE 5,5,5
  tbgl_PopMatrix  


  many2 = getHeight(0,0,3)


  tbgl_PushMatrix  
    tbGL_translate 0,many2,3
    TBGL_SCALE 0.2,0.2,0.2
    TBGL_m15drawmodel %Boje
    'TBGL_SCALE 5,5,5
  tbgl_PopMatrix  




  tbgl_PushMatrix  
    tbgl_translate manX, manY, manZ
    tbgl_rotate(dir,0,1,0)
    tbgl_rotate(tilt,1,0,0)
    tbgl_rotatexyz(0,0,roll)
    tbgl_CallList %powerboat
  tbgl_PopMatrix  


  tbgl_resetMatrix
  tbgl_UseLighting 0
  dirx = dirvec(1)
  diry = dirvec(2)
  dirz = dirvec(3)
  tbgl_PrintBMP "X:"+Format$(x, "#.00"), 0, 0, %TBGL_ALIGN_LEFT_UP
  tbgl_PrintBMP "Y:"+Format$(y, "#.00"), 10, 0, %TBGL_ALIGN_LEFT_UP
  tbgl_PrintBMP "Z:"+Format$(z, "#.00"), 20, 0, %TBGL_ALIGN_LEFT_UP


  tbgl_PrintBMP "dirX:"+Format$(dirx, "#.0000"), 0, 1, %TBGL_ALIGN_LEFT_UP
  tbgl_PrintBMP "dirY:"+Format$(diry, "#.0000"), 15, 1, %TBGL_ALIGN_LEFT_UP
  tbgl_PrintBMP "dirZ:"+Format$(dirz, "#.0000"), 30, 1, %TBGL_ALIGN_LEFT_UP


  tbgl_PrintBMP "FPS:"+framerate, 0, 2, %TBGL_ALIGN_LEFT_UP
  tbgl_PrintBMP "manY2:"+Format$(many2, "#.0000"), 15, 2, %TBGL_ALIGN_LEFT_UP
  tbgl_PrintBMP "Press H t reset the boats position", 0, 37, %TBGL_ALIGN_LEFT_UP
  tbgl_PrintBMP "dir:"+Format$(dir, "##.0000"), 0, 38, %TBGL_ALIGN_LEFT_UP
  tbgl_PrintBMP "speed:"+Format$(speed, "##.0000"), 30, 38, %TBGL_ALIGN_LEFT_UP
  
  tbgl_GetWindowClient hWnd, cX, cY      
  tbgl_UseLighting 1    
  tbgl_DrawFrame 


  If GetWindowKeyState( hWnd, %VK_Q) Then Exit While 


'  If GetWindowKeyState( hWnd, %VK_W) Then tilt += 30/framerate
'  If GetWindowKeyState( hWnd, %VK_S) Then tilt -= 30/framerate


  joyX = TBDI_JoyX(0)
  joyZ = TBDI_JoyZ(0)
  If joyZ = 0 And  GetWindowKeyState( hWnd, %VK_UP) Then joyZ = -1024
  If joyZ = 0 And  GetWindowKeyState( hWnd, %VK_DOWN) Then joyZ = 1024
  If joyX = 0 And  GetWindowKeyState( hWnd, %VK_LEFT) Then joyX = -1024
  If joyX = 0 And  GetWindowKeyState( hWnd, %VK_RIGHT) Then joyX = 1024


  ret = TBASS_ChannelSetAttributes(Channel, enginespeed, enginevol, 0)
  roll = 0
  'If GetWindowKeyState( hWnd, %VK_left) Then 
  If joyX<0 Then 
    dir += 30/framerate*(-joyx/1024)
    Rotatey(30/framerate*(-joyx/1024),dirvec)
    roll = 4*joyx/1024


  endif
  'If GetWindowKeyState( hWnd, %VK_right) Then 
  If joyX>0 Then  
    dir -= 30/framerate*(joyx/1024)
    Rotatey(-30/framerate*(joyx/1024),dirvec)
    roll = 4*joyx/1024
  endif


'  If GetWindowKeyState( hWnd, %VK_E) Then roll += 30/framerate
'  If GetWindowKeyState( hWnd, %VK_Q) Then roll -= 30/framerate


  'If GetWindowKeyState( hWnd, %VK_LEFT) Then yRot += 30/FrameRate
  'If GetWindowKeyState( hWnd, %VK_right) Then yRot -= 30/FrameRate
  'If GetWindowKeyState( hWnd, %VK_Up) Then xRot += 30/FrameRate
  'If GetWindowKeyState( hWnd, %VK_Down) Then xRot -= 30/FrameRate
  If GetWindowKeyState( hWnd, %VK_h) Then
    manx = 1
    many = -0.15
    manz = 1


    dir = 90
    speed = 0


    dirvec(1) = 1
    dirvec(2) = 0
    dirvec(3) = 0
    tilt = 0
    roll = 0
  endif


  
  if speed > 0 then
    speed -= 0.2
    tilt = joyz/512
  endif
  if speed < -0.1 then
    speed += 0.2
    tilt = joyz/1024
  endif
  if joyZ<0 then
    speed += 0.8*(-joyz/1024)
    enginespeed = 25000+-joyz*35
  endif
  if joyZ>0 then  
    speed -= 0.4*(joyz/1024)
    enginespeed = 25000+joyz*10
  endif
  if speed <> 0 then
    manx += dirX/framerate*speed/10
    many += diry/framerate*speed/10
    manz += dirz/framerate*speed/10
  endif  
  if dir > 360.0 then dir -= 360.0
  if dir < 0.0 then dir += 360.0
  if speed > 240 then speed = 240
  if speed < -430 then speed = -40
  
Wend 
TBASS_FREE
tbgl_m15ClearModel 1
tbgl_m15ClearModel 2
tbgl_m15ClearModel 3


TBGL_DestroyWindow 
 
function rotateX (mangle as single, mvec() as single)
  mangle = degtorad(mangle)
  mvec(2) = mvec(2) * cos(mangle) - mvec(3) * sin(mangle)
  mvec(3) = mvec(2) * sin(mangle) + mvec(3) * cos(mangle)
end function


function rotateY (mangle as single, mvec() as single)
  mangle = degtorad(mangle)
  mvec(1) = mvec(3) * sin(mangle) + mvec(1) * cos(mangle)
  mvec(3) = mvec(3) * cos(mangle) - mvec(1) * sin(mangle)
end function


function rotatez (mangle as single, mvec() as single)
  mangle = degtorad(mangle)
  mvec(1) = mvec(1) * cos(mangle) - mvec(2) * sin(mangle)
  mvec(2) = mvec(1) * sin(mangle) + mvec(2) * cos(mangle)
end function


FUNCTION ShowMessage( BYVAL es AS STRING, OPTIONAL BYVAL ReturnErrorCode AS LONG ) AS LONG
  DIM ErrorCode AS LONG
  IF ReturnErrorCode = %TRUE THEN
    ErrorCode = TBASS_ERRORGETCODE
  END IF
  MSGBOX 0, es & $CRLF & $CRLF & IIF$( ReturnErrorCode = %TRUE, "BASS Error code: " & ErrorCode, "" )
  FUNCTION = ErrorCode
END function


FUNCTION Sound_Init( ) AS LONG
  DIM _Version AS LONG
  FUNCTION = %FALSE
  '---Check if lib loads and is correct version
  _Version = TBASS_GetVersion
  If HIWRD( _Version ) <> %TBASS_VERSION Then
    ShowMessage "An incorrect version of BASS.DLL was loaded. Program aborted."
    EXIT FUNCTION
  END IF
  '---Setup output for the default device
  IF TBASS_INIT( - 1, 44100, %TBASS_DEVICE_3D, 0, 0 ) = 0 THEN
    ShowMessage "Can't initialize device. Program aborted"
    EXIT FUNCTION
  END IF
  'console_writeline("TBASS_Set3DFactors : " & iif$(tBASS_Set3DFactors(1, 1, 1)=%tbass_true, "OK", "Error") )


  ' Turn EAX off (volume=0), if error then EAX is not supported
  'If tBASS_SetEAXParameters(-1, 0, -1, -1) = %tbass_false Then
    'console_writeline("EAX is not supported. Error code: " & tBASS_ErrorGetCode)
  'end if


  TBASS_SETVOLUME( 50 )
  '---OK, if we are here all should be ok to start
  FUNCTION = %TRUE
  'console_writeline(repeat$(79,"-"))
  'console_writeline("Press a key to continue. You will asked to open a MONO audio file")
  'console_writeline("If ok you should listen audio from right to left back to right ... and so on")
  
  'console_waitkey
END FUNCTION


function getHeight(xf as single, yf as single, zf as single)
  local x,y,z as single
  local px,py as integer
  TBGL_Pos3DtoPos2D( xf, yf, zf, px, py )


  tbgl_GetPixelInfo px,py, %TBGL_PINFO_xyz, x, y, z
  function = y


end function
Issue Details
Issue Number 523
Project thinAir and Visual Designer
Category CodeBrowser
Status Confirmed
Priority 5 - Medium
Affected Version 1.9.2
Fixed Version (none)
Milestone (none)
Users able to reproduce bug 0
Users unable to reproduce bug 0
Assigned Users (none)
Tags (none)




16-05-2017 17:49
thinBasic MVPs
Just bumping this as it is still an issue in thinBasic 1.9.16.17

+ Reply