Here is the code.
It is basically the Quickstart 6 code ported directly to PureGDK. I add a few items but not much. You will need to download the Quickstart files for Darkbasic to get the media files.
mazesize=100
Dim maze$(mazesize,mazesize)
Procedure LoadMaze(filename$)
Shared maze$()
OpenFile(1,filename$)
line$=ReadString(1) ; read the Command Line data (my custom maze generator)
mazesize=Val(Mid(line$,FindString(line$,"/Y:",0)+3,FindString(line$," ",FindString(line$,"/Y:",0)+3))) ; (get actual mazesize for < 100,100)
For y = 0 To mazesize
line$=ReadString(1)
For x = 0 To mazesize
maze$(y,x)=Mid(line$,x,1)
If maze$(y,x)=" "
maze$(y,x)="."
EndIf
Next x
Next y
CloseFile(1)
if mazesize<100
for y = mazesize+1 to 100
for x = mazesize+1 to 100
maze$(y,x)="."
next x
next y
endif
EndProcedure
Procedure SetResolution(Width, Height, Depth, Flag=#CDS_FULLSCREEN)
Protected Result,dmScreenSettings.DEVMODE
dmScreenSettings\dmSize=SizeOf(DEVMODE)
dmScreenSettings\dmPelsWidth=Width
dmScreenSettings\dmPelsHeight=Height
dmScreenSettings\dmBitsPerPel=Depth
dmScreenSettings\dmFields=#DM_PELSWIDTH|#DM_PELSHEIGHT|#DM_BITSPERPEL
If ChangeDisplaySettings_(@dmScreenSettings, Flag)=#DISP_CHANGE_SUCCESSFUL
Result=#True
EndIf
ProcedureReturn Result
EndProcedure
;SetResolution(800,600,32)
Delay(30)
;/ Initialize PureBasic desktop library
ExamineDesktops()
;/ Show the PureGDK render window
OpenWindow(0,100,100,800,600,"DarkBasic Professional - PureGDK", #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_ScreenCentered)
hDBWnd=OpenDBWnd(WindowID(0),0,0,800,600)
MoveWindow_(hDBWnd,0,0,DesktopWidth(0),DesktopHeight(0),1)
;/ Set the window to the to the top of the z-order
dbSetWindowSize(800,600)
dbSyncRate(0)
dbHideMouse()
backcolor=dbRGB(0,0,0)
dbColorBackdrop(backcolor)
dbCLSFill(backcolor)
maxcubes=16
cubesize=200
collisionsize=Int(cubesize/10)
speed.f=0.20
angle.f=0.0
dbFogOn()
dbFogColor(backcolor,0)
dbFogDistance(Int(maxcubes)*cubesize)
dbSetCameraRange(1,Int(maxcubes)*cubesize)
dbSetTextSize(14)
;dbCLSfill(backcolor)
currdir$=GetCurrentDirectory()
mdir$=currdir$+"media\"
LoadMaze("level_0.maze")
dbAutoCamOff()
;---------------------------------------
; Load Textures
;---------------------------------------
dbLoadImage(mdir$+"/wall2.jpg",1,0)
dbLoadImage(mdir$+"/ground.jpg",2,0)
dbLoadImage(mdir$+"/wall.jpg",3,0)
dbLoadImage(mdir$+"/wall_m_37.jpg",4,0)
dbLoadImage(mdir$+"/ground.jpg",5,0)
dbLoadImage(mdir$+"/Compass2.png",7)
dbLoadImage(mdir$+"/Arrow.png",8)
;---------------------
; Compass
;---------------------
dbMakeObjectPlain(50000,10.0,10.0,1)
dbTextureObject(50000,7)
dbSetObjectTransparency(50000,#GDK_Basic3D_DrawFirstWithAlpha)
;dbSetObjectToCameraOrientation(50000)
dbMakeObjectPlain(50001,10.0,10.0,1)
dbTextureObject(50001,8)
dbSetObjectTransparency(50001,#GDK_Basic3D_DrawFirstWithAlpha)
dbShowObject(50000)
dbPositionObject(50000,50,37,70)
dbLockObjectOn(50000)
dbShowObject(50001)
dbPositionObject(50001,50,37,70)
dbLockObjectOn(50001)
;---------------------------------------
; Define walls, floors and ceilings
;---------------------------------------
For i = 0 To (maxcubes*maxcubes)
; walls
dbMakeObjectCube(100+i,cubesize)
dbTextureObject(100+i,1)
; floors
dbMakeObjectPlain(10000+i,cubesize,cubesize)
dbRotateObject(10000+i,90,0,0)
dbTextureObject(10000+i,2)
; ceiling
dbMakeObjectPlain(20000+i,cubesize,cubesize)
dbRotateObject(20000+i,270,0,0)
dbTextureObject(20000+i,3)
Next i
;-------------------
; mark up and down "staircase" boxes
;-------------------
dbMakeObjectBox(95000,Int(cubesize/3),Int(cubesize/4),Int(cubesize/3))
dbTextureObject(95000,4)
dbSetAmbientLight(30)
dbMakeLight(1)
dbMakeLight(2)
dbSetPointLight(1,0,0,0)
dbSetSpotLight(2,45,90)
dbColorLight(2,dbRGB(252,216,141))
dbColorLight(1,dbRGB(236,182,100))
dbColorLight(0,dbRGB(0,0,0))
For x = 1 To mazesize
For z = 1 To mazesize
If maze$(x,z)="U"
upx=x
upy=z
curr_x=upx*cubesize
curr_z=upy*cubesize
EndIf
If maze$(x,z)="D"
endx=x
endy=z
ending_x=endx*cubesize
ending_z=endy*cubesize
EndIf
Next z
Next x
dbPositionCamera(curr_x,0,curr_z)
oldpostionx=dbCameraPositionX()
oldpostionz=dbCameraPositionZ()
ry.f=45.0
dbCLSFill(backcolor)
Repeat
;-------------------------------------
; added some basic location information
; make it easier to move around and know
; where you are at
;--------------------------------------
kevx=Int(dbCameraPositionX()/cubesize)
kevz=Int(dbCameraPositionZ()/cubesize)
kevy=Int(dbCameraPositionY()/cubesize)
dbText(5,30,"X =")
dbText(40,30,Str(kevx))
dbText(85,30,"Y = ")
dbText(120,30,Str(kevz))
dbText(5,40,"Exit location")
dbText(5,50,"DX = ")
dbText(40,50,Str(endx))
dbText(85,50,"DY = ")
dbText(120,50,Str(endy))
;----------------------------
; added some speed adjustment keys
; Keypad + speeds up movement
; Keypad - slows down movement
; Keypad 5 returns speed to "normal"
;----------------------------
If dbKeyState(#VK_ADD)
speed.f=speed.f+0.001
EndIf
If dbKeyState(#VK_SUBTRACT)
speed.f=speed.f-0.001
EndIf
If dbKeyState(#VK_NUMPAD5)
speed.f=0.1
EndIf
;-------------------
; keep speed within a
; standard range (not to slow not to fast)
;-------------------
If speed.f<=0.0
speed.f=0.001
EndIf
If speed.f>0.5
speed.f=0.5
EndIf
; forward movement
If dbMouseClick()=1
dbMoveCamera(maxcubes*speed)
EndIf
; backward movement
If dbMouseClick()=2
dbMoveCamera(maxcubes*-1*speed)
EndIf
rx.f=dbWrapValue(rx.f+dbMouseMoveX())
dir_x.f=rx.f*-1
dbRotateCamera(0.0,rx.f,0.0)
; spin compass arrow based on direction faced
dbRotateObject(50001,0,0,dir_x.f+270)
tx=dbCameraPositionX()
tz=dbCameraPositionZ()
curr_x=Int(tx/cubesize)-Int(maxcubes/2)
curr_z=Int(tz/cubesize)-Int(maxcubes/2)
zzz=0
For zz=1 To maxcubes
For xx=1 To maxcubes
zzz=zzz+1
curposx=Int(curr_x)+xx
curposz=Int(curr_z)+zz
If curposx<=0
curposx=0
EndIf
If curposx>=mazesize
curposx=mazesize
EndIf
If curposz<=0
curposz=0
EndIf
If curposz>=mazesize
curposz=mazesize
EndIf
If maze$(Int(curposx),Int(curposz))="#"
dbShowObject(100+zzz)
dbPositionObject(100+zzz,curposx*cubesize,0.0,curposz*cubesize)
; collision detection
If maze$(Int(curposx),Int(curposz))="#"
If tx>=((curposx*cubesize)-(cubesize/2)-collisionsize) And tx<=((curposx*cubesize)+(cubesize/2)+collisionsize) And tz>=((curposz*cubesize)-(cubesize/2)-collisionsize) And tz<=((curposz*cubesize)+(cubesize/2)+collisionsize)
dbPositionCamera(oldpositionx,dbCameraPositionY(),oldpositionz)
oldpositionx=dbCameraPositionX()
oldpositionz=dbCameraPositionZ()
EndIf
EndIf
Else
dbHideObject(100+zzz)
EndIf
; install floor & ceiling
If maze$(Int(curposx),Int(curposz))=":" Or maze$(Int(curposx),Int(curposz))="S" Or maze$(Int(curposx),Int(curposz))="T" Or maze$(Int(curposx),Int(curposz))="D" Or maze$(Int(curposx),Int(curposz))="U"
If maze$(Int(curposx),Int(curposz))="D" Or maze$(Int(curposx),Int(curposz))="U"
dbShowObject(95000)
dbPositionObject(95000,curposx*cubesize,0.0,curposz*cubesize)
dbShowObject(10000+zzz)
dbPositionObject(10000+zzz,curposx*cubesize,(cubesize/2)*(-1),curposz*cubesize)
dbShowObject(20000+zzz)
dbPositionObject(20000+zzz,curposx*cubesize,(cubesize/2),curposz*cubesize)
Else
dbShowObject(10000+zzz)
dbPositionObject(10000+zzz,curposx*cubesize,(cubesize/2)*(-1),curposz*cubesize)
dbShowObject(20000+zzz)
dbPositionObject(20000+zzz,curposx*cubesize,(cubesize/2),curposz*cubesize)
EndIf
Else
dbHideObject(10000+zzz)
dbHideObject(20000+zzz)
EndIf
Next xx
Next zz
oldpositionx=dbCameraPositionX()
oldpositionz=dbCameraPositionZ()
dbPositionLight(1,dbCameraPositionX(),dbCameraPositionY(),dbCameraPositionZ())
dbPositionLight(2,dbCameraPositionX(),dbCameraPositionY(),dbCameraPositionZ())
dbColorLight(1,dbRGB(200+Int(Random(50)-25),120,60))
dbRotateLight(2,dbCameraAngleX(),dbCameraAngleY(),dbCameraAngleZ())
; show Frames Per Second
dbText(10,100,Str(dbScreenFPS()))
dbSync()
event=WindowEvent()
If dbKeyState(#VK_ESCAPE) Or event=#PB_Event_CloseWindow
Quit=1
EndIf
Until Quit
End
Slyvnr