I recently got my DARKGame studio DVD in and I was doing some tests and I was to see what you all think. I tried to make the most models show with the best performance. Keys: Arrows rotate and move the cube, and left ctrl jumps.
Code:
Rem Project: Tree Tests
Rem Created: Saturday, December 27, 2008
Rem ***** Main Source File *****
`Set up the prog
Set Display Mode 800, 640, 32, 1
Sync On : Sync Rate 60
Backdrop On : Color Backdrop 0
Fog On : Fog Distance 750 : Fog Color 0
`Se up the cam and ground texture
Load Image "mediagroundskin.jpg", 1
Autocam off
Position Camera 0, 0, 20, 0
Rotate Camera -15, 0, 0
`Set up the matrix and texture it
Make Matrix 1, 2000, 2000, 30, 30
Randomize Matrix 1, RND(4)
Prepare Matrix Texture 1, 1, 1, 1
Position Matrix 1, -1000, 0, -1000
Update matrix 1
`Load the first tree, add a LOD to it and make it transparent.
Load Object "mediatree 3.dbo", 1
Set Object Transparency 1, 4
Set Alpha Mapping On 1, 150
Load Object "medialo_tree 3.dbo", 2
Set Alpha Mapping On 2, 150
Set Object Transparency 2, 4
Add LOD to OBject 1, 2, 0, 150
Delete Object 2
Position Object 1, 50, Get Ground Height(1, 50, 50)-.25, 50
`Same as a above but with a dif tree
Load Object "mediatree 2.dbo", 2
Set Object Transparency 2, 4
Set Alpha Mapping On 2, 99
Load Object "medialo_tree 2.dbo", 3
Set Alpha Mapping On 3, 99
Set Object Transparency 3, 4
Add LOD to OBject 2, 3, 0, 150
Delete Object 3
Position Object 2, 50, Get Ground Height(1, 50, 50)-.25, 50
`Place a few trees around.
For X=3 to 148
Instance Object X, RND(1)+1
X#=RND(2000)-1000 : Z#=RND(2000)-1000 : Y#=Get Ground Height(1, X#, Z#)-.25
Position Object X, X#, Y#, Z#
YRotate Object X, RND(359)
Scale#=RND(50)+75
Scale Object X, Scale#, Scale#, Scale#
Next
`Load the rock.
Load Object "mediaRock 1.dbo", 149
X#=RND(2000)-1000 : Z#=RND(2000)-1000, : Y#=Get ground height(1, X#, Z#)
Position Object 149, X#, Y#, Z# : Scale Object 149, 50, 50, 50
`Place a few
For X=150 to 160
Instance Object X, 149
X#=RND(2000)-1000 : Z#=RND(2000)-1000 : Y#=Get Ground Height(1, X#, Z#)-.25
Position Object X, X#, Y#, Z#
YRotate Object X, RND(359)
Scale#=RND(25)+15
Scale Object X, Scale#, Scale#, Scale#
Next
`Load a flower
Load Object "mediaFlower 2.dbo", 161
Set Object Transparency 2, 4
Set Alpha Mapping On 161, 99
X#=RND(2000)-1000 : Z#=RND(2000)-1000, : Y#=Get ground height(1, X#, Z#)
Position Object 161, X#, Y#, Z# : Scale Object 161, 8, 8, 8
`Place a few
For X=162 to 180
Instance Object X, 161
X#=RND(2000)-1000 : Z#=RND(2000)-1000 : Y#=Get Ground Height(1, X#, Z#)-.25
Position Object X, X#, Y#, Z#
YRotate Object X, RND(359)
Scale#=RND(5)+5
Scale Object X, Scale#, Scale#, Scale#
Next
`Load grass
Load Object "mediaGrass 1.dbo", 181
Set Object Transparency 2, 4
Set Alpha Mapping On 181, 99
X#=RND(2000)-1000 : Z#=RND(2000)-1000, : Y#=Get ground height(1, X#, Z#)
Position Object 181, X#, Y#, Z# : Scale Object 181, 18, 18, 18
`Place some
For X=182 to 225
Instance Object X, 181
X#=RND(2000)-1000 : Z#=RND(2000)-1000 : Y#=Get Ground Height(1, X#, Z#)-.25
Position Object X, X#, Y#, Z#
YRotate Object X, RND(359)
Scale#=RND(5)+15
Scale Object X, Scale#, Scale#, Scale#
Next
`Make you
Make Object Cube 226, 10
Position Object 226, 0, Get Ground Height(1, 0, 0)+5.25, 0
`Main
Do
`Controls to move
If UpKey()=1
Move Object 226, 2
Endif
If DownKey()=1
Move Object 226, -2
Endif
If RightKey()=1
Rotate#=Rotate#+1.5
Rotate#=Wrapvalue(Rotate#)
YRotate Object 226, Rotate#
Endif
If LeftKey()=1
Rotate#=Rotate#-1.5
Rotate#=Wrapvalue(Rotate#)
YRotate Object 226, Rotate#
Endif
`Decide if jumping or not
If Keystate(29)=1 and Jmp=0
Jmp=1
NewJump#=2.75
Endif
`If jumping, do what these comments say in...
If Jmp=1
G#=9.81/Screen FPS() : `Set gravity to be constant no matter the FPS.
NewJump#=NewJump#-G# : `Decrease how fast the cube is moving up or down during depending on the gravity.
Jump(NewJump#) : `Do the jump.
OPY#=(Get Ground height(1, Object Position X(226), Object Position Z(226))+5.25)
If Object Position Y(226) < OPY# : `If the cube is below the matrix, land it and stop the jump.
Jmp=0
Endif
Endif
Set Camera To Follow Object Position X(226), Object Position Y(226), Object Position Z(226), Rotate#, 55, 15, 3, 0 : `Make the cam follow the cube
Text 10, 10, "POLYGONS = "+str$(statistic(1)) : `Display the shown Polys and fps
Text 10, 20, "FPS = "+Str$(Screen FPS())
Sync
Loop
Function Jump(Str#) : `Jump, position it due to the strength of the jump or fall.
Position Object 226, Object Position X(226), Object Position Y(226)+Str#, Object Position Z(226)
Endfunction
SS:
I started to program in DBC a while ago, and now I moved on to DBPro, so I do have a little experiance, and I hope to continue it.