(Der Code braucht die gleichen Includes und Mesh-Texture-Files wie das Entity-Beispiel, das bei PB4.0b1 dabei ist, er sollte demnach eigentlich problemlos laufen, wenn er als "PureBasic4.0beta1-ORDNER\Examples\Sources\irgendwas.pb" )
Code: Alles auswählen
;
; ------------------------------------------------------------
;
; PureBasic - Entity
;
; (c) 2002 - Fantaisie Software
;
; ------------------------------------------------------------
;
IncludeFile "Screen3DRequester.pb"
Define.f KeyX, KeyY, MouseX, MouseY
If InitEngine3D()
Add3DArchive("Data\" , #PB_3DArchive_FileSystem)
Add3DArchive("Data\Skybox.zip", #PB_3DArchive_Zip)
InitSprite()
InitKeyboard()
InitMouse()
If Screen3DRequester()
LoadMesh (0, "Robot.mesh")
CreateMaterial(0, LoadTexture(0, "clouds.jpg"))
CreateMaterial(1, LoadTexture(1, "r2skin.jpg"))
CreateEntity(0, MeshID(0), MaterialID(0))
CreateEntity(1, MeshID(0), MaterialID(1), -60, 0, 0)
CreateEntity(2, MeshID(0), MaterialID(1), 60, 0, 0)
AnimateEntity(0, "Walk")
SkyBox("desert07.jpg")
CreateCamera(0, 0, 0, 100, 100)
CameraLocate(0,0,0,100)
Debug EnableWorldCollisions(1)
Repeat
Screen3DEvents()
ClearScreen(RGB(0, 0, 0))
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_F11)
MoveEntity(0,-5,0,0)
EndIf
If KeyboardPushed(#PB_Key_F12)
MoveEntity(0,5,0,0)
EndIf
If KeyboardPushed(#PB_Key_Left)
KeyX = -1
ElseIf KeyboardPushed(#PB_Key_Right)
KeyX = 1
Else
KeyX = 0
EndIf
If KeyboardPushed(#PB_Key_Up)
KeyY = -1
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY = 1
Else
KeyY = 0
EndIf
If KeyboardPushed(#PB_Key_PageUp)
RollZ = 3
Else
RollZ = 0
EndIf
If KeyboardPushed(#PB_Key_Add)
Frame.f+0.005
EndIf
EndIf
If ExamineMouse()
MouseX = -MouseDeltaX()/10
MouseY = -MouseDeltaY()/10
EndIf
RotateEntity(1, 1, 0, 0)
RotateEntity(2, 1, 0, 0)
RotateCamera(0, MouseX, MouseY, RollZ)
MoveCamera (0, KeyX, 0, KeyY)
a = ExamineWorldCollisions()
Debug a
Debug ""
Debug CheckEntityCollision(0,1)
Debug CheckEntityCollision(0,2)
Debug ""
If a
While NextWorldCollision()
Debug FirstWorldCollisionEntity()
Debug SecondWorldCollisionEntity()
Debug "---------------------------"
Wend
EndIf
RenderWorld()
Screen3DStats()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
End