the following code (with help from Dark Dragon) creates a 10 X 10 floor... a plane of water and a 100X10 ceiling. This takes about 3 seconds on my cpu and about 9 seconds on my wifes CPU... (you have to turn the mouse around to turn the camera - I still cannot get it to look at the #DUDE entity!)
now the biggie. I am going to random up a map. I will attempt to plop floor tiles down on this map. I suspect I will need to plop wall tiles as well or I may overload the grpahics card...
sharing the code so far:
Code: Select all
;
; ------------------------------------------------------------
;
; PureBasic - Terrain
;
; modified by Ralph W Dunn / Rook ZImbabwe
; (c) 2003 - Fantaisie Software
; modified 7 MARCH 2011
; Changes applied from examples by Daniel (Dark Dragon)
;
; ------------------------------------------------------------
;
version$ = "0.07b"
#CameraSpeed = 0.4
#Thing1 = 1
#CRETE = 2
#PLAYER = 3
#DUDE = 4
#BALL = 5
Global Dim stones(10,10)
IncludeFile "Screen3DRequester.pb"
Define.f KeyX, KeyY, MouseX, MouseY
Procedure Scatter()
For x = 0 To 10
For z = 0 To 10
chip = Random(1)
stones(x,z) = chip
Next
Next
EndProcedure
If InitEngine3D()
Add3DArchive("Data", #PB_3DArchive_FileSystem)
InitSprite()
InitKeyboard()
InitMouse()
EnableWorldPhysics(#True)
EnableWorldCollisions(#True)
WorldGravity(98.1) ; (98.1) ; roughly 1/3 gravity [ slower fall]
If Screen3DRequester()
;AmbientColor(RGB(255,255,255))
LoadMesh (#BALL , "BALL0.mesh") ; a block or cube... can be gotten from my basic MESH pack
LoadTexture(99, "glop0.png") ; something to make it look nice
LoadMesh (0 , "thing1.mesh") ; a block or cube... can be gotten from my basic MESH pack
LoadTexture(0, "RUST1.jpg") ; something to make it look nice
CreateMaterial(#CRETE, TextureID(0))
balltex = CreateMaterial(#PB_Any, TextureID(99))
CreateEntity(#BALL, MeshID(#BALL), MaterialID(balltex),25,10,25)
CreateEntity(#Thing1, MeshID(0), MaterialID(#CRETE),0,0,0)
EntityPhysicBody(#BALL, #PB_Entity_SphereBody, #PB_Entity_AbsoluteBodyMove)
SetEntityMass(#BALL, 1.1)
scatter() ; make random squares for ceiling
; throw down a floor for gravity to work on
ey = 0
ez = 0
For cx = 0 To 10
For cy = 0 To 10
Result = CopyEntity(#Thing1, #PB_Any)
EntityLocate(Result, ey, 0, ez)
EntityPhysicBody(Result, #PB_Entity_StaticBody)
SetEntityMass(Result, 10.0)
ez = ez + 7
Next
ey = ey + 7
ez = 7
Next
; ******** READ RANDOM SQUARES
ey = 0
ez = 0
For cx = 0 To 10
For cy = 0 To 10
xc = stones(cx,cy)
If xc = 1
Result = CopyEntity(#Thing1, #PB_Any)
EntityLocate(Result, ey, 37, ez)
EntityPhysicBody(Result, #PB_Entity_StaticBody)
SetEntityMass(Result, 10.0)
EndIf
ez = ez + 7
Next
ey = ey + 7
ez = 7
Next
; make something to see the floor with
CreateCamera(#PLAYER, 0, 0, 100, 150)
CameraLocate(#PLAYER, 10, 15, 0)
CreateWater(#PLAYER, 0,-1,0, 190,#PB_World_WaterMediumQuality)
SkyDome("blue_sky_1.jpg",-10) ; my clouds texture...
;WorldDebug(#PB_World_DebugEntity) ; #PB_World_DebugEntity / #PB_World_DebugBody = no work
Repeat
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_A)
KeyY = -2
rotX = 1 ;#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_D)
KeyY = 2
rotX = -1 ;#CameraSpeed
Else
KeyY = 0
rotX = 0
EndIf
If KeyboardPushed(#PB_Key_W)
KeyX = 2 ;#CameraSpeed
rotY = -1
ElseIf KeyboardPushed(#PB_Key_X)
KeyX = -2 ;#CameraSpeed
rotY = 1
Else
KeyX = 0
rotY = 0
EndIf
EndIf
If ExamineMouse()
MouseX = -(MouseDeltaX()/10)*#CameraSpeed ; dropped the /2 cause it was slowing me down
MouseY = -(MouseDeltaY()/10)*#CameraSpeed
EndIf
; to move the new node entity
;RotateEntity(#Thing1, MouseY, MouseX, RollZ, #PB_Relative)
RotateCamera(#PLAYER, MouseY, MouseX, RollZ, #PB_Relative)
RotateEntity(#BALL,rotX, 0, rotY, #PB_Relative)
MoveEntity(#BALL, KeyX, 0, KeyY)
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
End
http://www.bluemesapc.com/Downloads/terrain.zip -- about 3.7ish M because of graphics and models in Data folder
I sincerely wish the Create Plain commands from OGRE were implemented...


