the following 2 programs are nothing more than arrange spheres over each other, the first one are rectangles which are given the physics of spheres, they still spheres but with a shape of a rectangle, it behaves like a spring, but don't expect to put a block over it other than a suitable sphere else it will collapse
Code: Select all
Enumeration
#plane
#cube
#ball
#Cone
#Tube_extension
EndEnumeration
Quit.b = #False
ExamineDesktops()
OpenWindow(3, 0, 0, DesktopWidth(0), DesktopHeight(0), "Arrow keys and mouse to move/rotate .... Space ...to push the spring ", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
;Initialize environment
InitEngine3D()
InitSprite()
OpenWindowedScreen(WindowID(3), 0, 0, DesktopWidth(0), DesktopHeight(0), 0, 0, 0)
InitKeyboard()
InitMouse()
SetFrameRate(60)
Add3DArchive(".", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Textures", #PB_3DArchive_FileSystem)
CreateMaterial(1, LoadTexture(1, "clouds.jpg"))
CreatePlane(#plane, 20, 20, 1, 1, 1, 1)
CreateEntity (#plane, MeshID(#plane), MaterialID(1))
MoveEntity(#plane,0,-6,0)
EntityPhysicBody(#plane, #PB_Entity_StaticBody)
CreateLight(0,RGB(255,255,255),-100,40,30)
AmbientColor(RGB(100,100,100))
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 0, 4, 12)
MoveCamera(0, 7, -5, 0)
;RotateCamera(0, -60,90,0)
CameraLookAt(0, 0, -5, 0)
CreateMaterial(0, LoadTexture(0, "wood.jpg"))
CreateMaterial(1, LoadTexture(1, "wood.jpg"))
MaterialCullingMode(0, #PB_Material_NoCulling)
;MaterialBlendingMode(0, #PB_Material_AlphaBlend )
MaterialShadingMode(0, #PB_Material_Wireframe)
DisableMaterialLighting(0, 1)
CreateMesh(1, #PB_Mesh_TriangleList, #PB_Mesh_Static )
SetMeshMaterial(1, MaterialID(0))
CreateMaterial(3, LoadTexture(3, "white.jpg"))
SetMaterialColor(3, #PB_Material_SelfIlluminationColor, RGB(255,0,0))
CreateCube(#cube,1)
Global r
y.f = -5.9
For i=0 To 6
OneBlock = CreateEntity(#PB_Any, MeshID(#cube), MaterialID(3))
ScaleEntity(OneBlock, 0.5, 0.2, 3)
y = y + 0.2
MoveEntity(OneBlock, 2.0, y, -1.5, #PB_Absolute)
SetMaterialColor(3, #PB_Material_SelfIlluminationColor, RGB(255,0,0))
EntityPhysicBody(OneBlock, #PB_Entity_SphereBody, 1,0,10)
Next
;Last block
OneBlock = CreateEntity(#PB_Any, MeshID(#cube), MaterialID(3))
ScaleEntity(OneBlock, 0.5, 0.2, 6)
y = y + 0.2
MoveEntity(OneBlock, 2.0, y, -1.5, #PB_Absolute)
EntityPhysicBody(OneBlock, #PB_Entity_SphereBody, 50,0,10)
WorldDebug(#PB_World_DebugBody)
ExamineKeyboard()
Global.f keyX, ketY, MouseY, MouseX
EntityPhysicBody(#ball, #PB_Entity_SphereBody, 22,3,1)
Repeat
Event = WindowEvent()
If KeyboardPushed(#PB_Key_Space)
ApplyEntityImpulse(OneBlock, 0, -15, 0)
EndIf
If ExamineMouse()
MouseX = -MouseDeltaX()/10
MouseY = -MouseDeltaY()/10
EndIf
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
KeyX.f = -0.2
ElseIf KeyboardPushed(#PB_Key_Right)
KeyX.f = 0.2
Else
KeyX.f = 0
EndIf
If KeyboardPushed(#PB_Key_Up)
KeyY.f = -0.2
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY.f = 0.2
Else
KeyY.f = 0
EndIf
EndIf
RotateCamera(0, MouseY, MouseX, 0, #PB_Relative)
MoveCamera (0, KeyX.f, 0, KeyY.f)
RenderWorld()
FlipBuffers()
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Escape)
Quit = #True
EndIf
Until Quit = #True Or Event = #PB_Event_CloseWindow
Code: Select all
Enumeration
#plane
#Ball
#BigBall
#Cone
#Tube_extension
EndEnumeration
Quit.b = #False
ExamineDesktops()
OpenWindow(3, 0, 0, DesktopWidth(0), DesktopHeight(0), "Arrow keys and mouse to move/rotate .... Space .to push the ball ", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
;Initialize environment
InitEngine3D()
InitSprite()
OpenWindowedScreen(WindowID(3), 0, 0, DesktopWidth(0), DesktopHeight(0), 0, 0, 0)
InitKeyboard()
InitMouse()
SetFrameRate(60)
Add3DArchive(".", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Textures", #PB_3DArchive_FileSystem)
CreateMaterial(1, LoadTexture(1, "clouds.jpg"))
CreateCube(#plane, 1)
CreateEntity (#plane, MeshID(#plane), MaterialID(1))
ScaleEntity(#plane, 50,0.2,50)
MoveEntity(#plane,0,0,0)
EntityPhysicBody(#plane, #PB_Entity_StaticBody)
CreateLight(0,RGB(255,255,255),-100,40,30)
AmbientColor(RGB(100,100,100))
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 0, 4, 12)
MoveCamera(0, 35, 30, 130)
;RotateCamera(0, -60,90,0)
CameraLookAt(0, 0, 40, 0)
;CreateMaterial(0, LoadTexture(0, "terrain_texture.jpg"))
CreateMaterial(0, LoadTexture(0, "wood.jpg"))
CreateMaterial(1, LoadTexture(1, "wood.jpg"))
MaterialCullingMode(0, #PB_Material_NoCulling)
;MaterialBlendingMode(0, #PB_Material_AlphaBlend )
MaterialShadingMode(0, #PB_Material_Wireframe)
DisableMaterialLighting(0, 1)
CreateMesh(1, #PB_Mesh_TriangleList, #PB_Mesh_Static )
SetMeshMaterial(1, MaterialID(0))
CreateMaterial(3, LoadTexture(3, "white.jpg"))
SetMaterialColor(3, #PB_Material_SelfIlluminationColor, RGB(255,0,0))
CreateSphere(#BigBall, 2)
CreateEntity(#BigBall, MeshID(#BigBall), MaterialID(3), 22,10,12)
CreateSphere(#Ball,1)
xdisp.f = -16
For c = 0 To 3
z.f + 3 : xdisp=0
For j = 0 To 3
y.f = 0.0
xdisp.f + 3
For i=0 To 45
OneBlock = CreateEntity(#PB_Any, MeshID(#Ball), MaterialID(3))
y = y + 2
MoveEntity(OneBlock, xdisp, y, -1.5+z, #PB_Absolute)
SetMaterialColor(3, #PB_Material_SelfIlluminationColor, RGB(255,0,0))
EntityPhysicBody(OneBlock, #PB_Entity_SphereBody, 1,0,10)
Next
Next
Next
;WorldDebug(#PB_World_DebugBody)
ExamineKeyboard()
Global.f keyX, ketY, MouseY, MouseX
EntityPhysicBody(#BigBall, #PB_Entity_SphereBody, 22,3,1)
Repeat
Event = WindowEvent()
If KeyboardPushed(#PB_Key_Space)
ApplyEntityImpulse(#BigBall, -20, 0,0)
;Debug r
EndIf
If ExamineMouse()
MouseX = -MouseDeltaX()/10
MouseY = -MouseDeltaY()/10
EndIf
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_X)
MessageRequester("", Str(meshesNum) + "=== "+Str(sss))
EndIf
If KeyboardPushed(#PB_Key_Left)
KeyX = -0.5
ElseIf KeyboardPushed(#PB_Key_Right)
KeyX = 0.5
Else
KeyX = 0
EndIf
If KeyboardPushed(#PB_Key_Up)
KeyY = -0.5
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY = 0.5
Else
KeyY = 0
EndIf
EndIf
RotateCamera(0, MouseY, MouseX, 0, #PB_Relative)
MoveCamera (0, KeyX, 0, KeyY)
RenderWorld()
FlipBuffers()
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Escape)
Quit = #True
EndIf
Until Quit = #True Or Event = #PB_Event_CloseWindow

