See here:
http://www.purebasic.fr/english/viewtop ... =labyrinth
Or this example code here which works with 4.20:
Code: Select all
InitEngine3D()
InitSprite()
InitKeyboard()
InitMouse()
OpenWindow(0,0,0,800,600,"Dungeon")
OpenWindowedScreen(WindowID(0),0,0,800,600,0,0,0)
#CameraSpeed = 10
Define.f KeyX, KeyY, MouseX, MouseY
AmbientColor(RGB(128,128,128))
; Create a plan, manually
;
CreateMesh(1,100)
SetMeshData(1, #PB_Mesh_Vertex | #PB_Mesh_Normal | #PB_Mesh_UVCoordinate, ?PlanVertices, 4)
SetMeshData(1, #PB_Mesh_Face, ?PlanFaces, 4)
CreateTexture(1,64,64)
StartDrawing(TextureOutput(1))
Box(0,0,64,64,#Blue)
Box(1,1,62,62,#Yellow)
StopDrawing()
CreateMaterial(1, TextureID(1))
Restore Level
For z=1 To 6
For x=1 To 6
Read Title
If Title = 1
Entity=CreateEntity (#PB_Any, MeshID(1), MaterialID(1))
RotateEntity(entity,0,90,0)
ScaleEntity(entity, 64, 1, 64)
EntityLocate(entity,x*64,0,z*64)
ElseIf Title = 2
Entity=CreateEntity (#PB_Any, MeshID(1), MaterialID(1))
RotateEntity(entity,0,0,90)
ScaleEntity(entity, 64, 1, 64)
EntityLocate(entity,x*64,0,z*64)
EndIf
Next x
Next z
CreateLight(0, RGB(255,255,255), 100.0, 100, 0)
CreateCamera(0, 0, 0, 100, 100)
CameraLocate(0,0,50,100)
CameraLookAt(0,EntityX(entity),EntityY(entity),EntityZ(entity))
Repeat
ClearScreen(0)
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
KeyX = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Right)
KeyX = #CameraSpeed
Else
KeyX = 0
EndIf
If KeyboardPushed(#PB_Key_Up)
KeyY = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY = #CameraSpeed
Else
KeyY = 0
EndIf
EndIf
If ExamineMouse()
MouseX = -(MouseDeltaX()/10)*#CameraSpeed/2
MouseY = -(MouseDeltaY()/10)*#CameraSpeed/2
EndIf
RotateCamera(0, MouseX, MouseY, RollZ)
MoveCamera (0, KeyX, 0, KeyY)
LightLocate(0, CameraX(0)+100, CameraY(0), CameraZ(0))
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
End
DataSection
PlanVertices:
; Note normals are important component to allow correct light support (and therefore shadow)
;
Data.f -0.5, 0, -0.5 ; Vertex 0
Data.f 1, 1, 1 ; Normals (perpendicular to the plan)
Data.f 0 , 1 ; UVCoordinate
Data.f 0.5, 0, -0.5 ; Vertex 1
Data.f 1,1,1 ; Normals
Data.f 1, 1 ; UVCoordinate
Data.f 0.5, 0, 0.5 ; Vertex 2
Data.f 1,1,1 ; Normals
Data.f 1, 0 ; UVCoordinate
Data.f -0.5, 0, 0.5 ; Vertex 3
Data.f 1,1,1 ; Normals
Data.f 0, 0 ; UVCoordinate
PlanFaces:
Data.w 2, 1, 0 ; bottom face (clockwise as it's reversed...)
Data.w 0, 3, 2
Data.w 0, 1, 2
Data.w 2, 3, 0
Level:
Data.l 1,1,1,1,1,1
Data.l 2,0,2,0,0,2
Data.l 2,0,0,0,0,2
Data.l 2,0,1,1,0,2
Data.l 2,0,0,0,0,2
Data.l 1,1,1,1,1,1
EndDataSection


