C'est tous simple j'ai repris l'exemple de Fred et je l'ai modifier.
Code : Tout sélectionner
; ODE Test 2 by CameleonTH
#PB_Entity_StaticBody = 1
#PB_Entity_BoxBody = 2
#PB_Entity_SphereBody = 3
InitEngine3D()
InitSprite()
InitKeyboard()
InitMouse()
OpenWindow(0,10,10,640,480,0,"test2")
OpenWindowedScreen(WindowID(0),0,0,640,480,1,1,1)
AmbientColor(RGB(128,128,128))
Add3DArchive("Data\" , #PB_3DArchive_FileSystem)
EnableWorldPhysics(1)
WorldGravity(35)
EnableWorldCollisions(1)
Parse3DScripts()
SkyBox("1.jpg")
map = LoadMesh(#PB_Any, "mapode2.mesh")
sphere = LoadMesh(#PB_Any, "sphere.mesh")
mapentity = CreateEntity(#PB_Any , MeshID(map), 0, 0, 0, 0)
EntityPhysicBody(mapentity, #PB_Entity_StaticBody)
ScaleEntity(mapentity, 0.5, 0.5, 0.5)
EntityRenderMode(mapentity, 0)
sphereentity = CreateEntity(#PB_Any , MeshID(sphere), 0, -100, 100, 50)
EntityPhysicBody(sphereentity, #PB_Entity_SphereBody)
ScaleEntity(sphereentity, 0.05, 0.05, 0.05)
SetEntityMass(sphereentity, 75)
SetEntityFriction(sphereentity, 1)
sphereentity = CreateEntity(#PB_Any , MeshID(sphere), 0, -115, 100, 50)
EntityPhysicBody(sphereentity, #PB_Entity_SphereBody)
ScaleEntity(sphereentity, 0.05, 0.05, 0.05)
SetEntityMass(sphereentity, 75)
SetEntityFriction(sphereentity, 1)
sphereentity = CreateEntity(#PB_Any , MeshID(sphere), 0, -130, 100, 50)
EntityPhysicBody(sphereentity, #PB_Entity_SphereBody)
ScaleEntity(sphereentity, 0.05, 0.05, 0.05)
SetEntityMass(sphereentity, 75)
SetEntityFriction(sphereentity, 1)
sphereentity = CreateEntity(#PB_Any , MeshID(sphere), 0, -100, 125, 50)
EntityPhysicBody(sphereentity, #PB_Entity_SphereBody)
ScaleEntity(sphereentity, 0.05, 0.05, 0.05)
SetEntityMass(sphereentity, 75)
SetEntityFriction(sphereentity, 1)
sphereentity = CreateEntity(#PB_Any , MeshID(sphere), 0, -115, 125, 50)
EntityPhysicBody(sphereentity, #PB_Entity_SphereBody)
ScaleEntity(sphereentity, 0.05, 0.05, 0.05)
SetEntityMass(sphereentity, 75)
SetEntityFriction(sphereentity, 1)
sphereentity = CreateEntity(#PB_Any , MeshID(sphere), 0, -115, 150, 50)
EntityPhysicBody(sphereentity, #PB_Entity_SphereBody)
ScaleEntity(sphereentity, 0.05, 0.05, 0.05)
SetEntityMass(sphereentity, 75)
SetEntityFriction(sphereentity, 1)
CreateLight(0, RGB(255,255,255), 100.0, 100, 0)
CreateCamera(0, 0, 0, 100, 100)
CameraLocate(0,-100,80,15)
Repeat
WindowEvent()
ClearScreen(RGB(0, 0, 0))
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_space)
sphereentity = CreateEntity(#PB_Any , MeshID(sphere), 0, 15, 350, 0)
EntityPhysicBody(sphereentity, #PB_Entity_SphereBody)
ScaleEntity(sphereentity, 0.1, 0.1, 0.1)
SetEntityMass(sphereentity, 75)
SetEntityFriction(sphereentity, 0.5)
EndIf
If KeyboardPushed(#PB_Key_return)
sphereentity = CreateEntity(#PB_Any , MeshID(sphere), 0, -115, 150, 50)
EntityPhysicBody(sphereentity, #PB_Entity_SphereBody)
ScaleEntity(sphereentity, 0.05, 0.05, 0.05)
SetEntityMass(sphereentity, 75)
SetEntityFriction(sphereentity, 0.5)
EndIf
If KeyboardPushed(#PB_Key_Left)
KeyX.f = -1
ElseIf KeyboardPushed(#PB_Key_Right)
KeyX.f = 1
Else
KeyX.f = 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_Pad0)
KeyZ = 1
ElseIf KeyboardPushed(#PB_Key_RightControl)
KeyZ = -1
Else
KeyZ = 0
EndIf
EndIf
If ExamineMouse()
MouseX = -MouseDeltaX()/5
MouseY = -MouseDeltaY()/5
EndIf
RotateCamera(0, MouseX, MouseY, RollZ)
MoveCamera (0, KeyX, KeyZ, KeyY)
If ExamineWorldCollisions()
While NextWorldCollision()
Wend
EndIf
RenderWorld()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1