I share this small program, maybe can help someone that is at the beginning of the journey like me. Also show how magic the feature [IDEGUIADD] is !
Before start the program make sure to have :
Edit --> Preferences --> Editor ( check Enable Code Properties )
Edit --> Preferences --> Build Options ( chec0k: On Debug Start, Update Watches, Status also check : On Debug Try to Bring App to Front )
Debugger Tab --> (check: Auto Update )
Image Setting:
https://www.dropbox.com/s/amny5bu0hmkrir9/Setting.png?dl=0
In action:
https://www.youtube.com/watch?v=JFpM8zz_4vA
Lunch the program in Debug mode for enjoy the Live Editing of Code!
Download:
https://www.dropbox.com/s/1f1f2jwepwptbz5/Heigh%20Map%20Generator.zip?dl=0
( Contains 2 media files .png , greyscale 8 bit )
SetErrorMode(2)
SetWindowTitle("HeighMap Generator")
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 )
SetVirtualResolution( 1024, 768 )
SetSyncRate( 60, 0 )
UseNewDefaultFonts( 1 )
////////////////////////////////////////// Display
global W as float : W = GetDeviceWidth()
global H as float : H = GetDeviceHeight()
global WH as float : WH = W/H
SetDisplayAspect(W/H)
////////////////////////////////////////// Debug
Global Debug=1
if Debug=1
CreateObjectPlane(1,1,1):SetObjectColor(1,0,255,0,255)
SetCameraPosition(1,0,0,-4)
SetCameraRotation(1,0,0,0)
endif
////////////////////////////////////////// Generate Height Map
gosub MakeMap
SetAmbientColor(2,2,2)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
do
if trigger= 1
for i=1 to 1
DeleteObject(MapH)
MapH=CreateObjectFromHeightMap( MapH$, MapHW#, MapHH#, MapHL#, MSmoH#, 1 )
next i
trigger=0
endif
SetObjectPosition(MapH,Mx#,My#,Mz#)
debugcamera()
Print( ScreenFPS() )
Sync()
loop
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
MakeMap:
//[IDEGUIADD],header,Height Map
global trigger= 0 //[IDEGUIADD],integer,Update Map
global MapH$ = "Map01.png"//[IDEGUIADD],selectfile,Select image file
global MapHW# = 300 //[IDEGUIADD],integer,Map Width
global MapHH# = 1 //[IDEGUIADD],integer,Map Height
global MapHL# = 300 //[IDEGUIADD],integer,Map Lenght
global MSmoH# = 1 //[IDEGUIADD],integer,Smoothing Level
//[IDEGUIADD],separator,
MapH=CreateObjectFromHeightMap( MapH$, MapHW#, MapHH#, MapHL#, MSmoH#, 1 )
//[IDEGUIADD],header,Move Map
global Mx#=0.000000 //[IDEGUIADD],float,Mxz
global My#=0.000000 //[IDEGUIADD],float,MYz
global Mz#=0.000000 //[IDEGUIADD],float,MZz
//[IDEGUIADD],separator,
RETURN
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function debugcamera()
if Debug=1
drawline(0,H/2,W,H/2,255,0,0)
drawline(W/2,0,W/2,H,255,0,0)
endif
if GetRawKeyState(65) then MoveCameraLocalX(1,-0.1) //Move left A
if GetRawKeyState(68) then MoveCameraLocalX(1,0.1) //Move right D
if GetRawKeyState(87) then MoveCameraLocalZ(1,0.1) //Move Forward W
if GetRawKeyState(83) then MoveCameraLocalZ(1,-0.1) //Bove Back S
if GetRawKeyState(69) then MoveCameraLocalY(1,0.1) //Move Up E
if GetRawKeyState(81) then MoveCameraLocalY(1,-0.1) //Move Down Q
if GetRawKeyState(39) then RotateCameraGlobalY(1,0.5) //Camera Right ArrowRight
if GetRawKeyState(37) then RotateCameraGlobalY(1,-0.5) //Camera Left ArrowLeft
if GetRawKeyState(40) then RotateCameraLocalX(1,0.5) //Camera Up ArrowUp
if GetRawKeyState(38) then RotateCameraLocalX(1,-0.5) //Camera Down ArrowDown
if GetButtonPressed(1)=1 then SetCameraPosition(1,0,0,-4) //ResetCamera SpaceBar
if GetButtonPressed(1)=1 then SetCameraRotation(1,0,0,0) //ResetCamera SpaceBar
endfunction
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
From linee 46 to 51 , change integer to float , if you want use them.