I recently got Advanced Terrain and used the example code to start a game I am making. I want to add in a object such as a character and view them in 3rd Person style and walk around etc. Can someone just give me some basic code on how to put a sphere or cube in and the walk around with it in 3rd person?
Here is the code -
`Game - Work in Progress
`Get Display
w = d3d_Get_Desktop_Width()
h = d3d_Get_Desktop_Height()
`Start Game
Set Window Off
Set Window Title "Game"
Set Display Mode w, h, 32
` set up display and camera
sync on
hide mouse
backdrop on
autocam off
set camera range 0.5, 30000
` set the directory to media
set dir "media"
` load base and detail texture
load image "texture.bmp", 1
load image "detail.tga", 2
make object terrain 1 ` create the terrain object
set terrain heightmap 1, "map.bmp" ` set the heightmap
set terrain scale 1, 3, 0.6, 3 ` set the scale
set terrain split 1, 16 ` split value by 16 * 16
set terrain tiling 1, 4 ` detail map tiling
set terrain light 1, 1, -0.25, 0, 1, 1, 0.78, 0.5 ` light - xdir, ydir, zdir, red, green, blue, intensity
set terrain texture 1, 1, 2 ` base and detail texture
build terrain 1 ` finally build the terrain
`Load some fog onto our map
Fog On
Fog Color 128, 128, 128
Fog Distance 1000
` load our skybox
load object "skybox2.x", 200
set object light 200, 0
set object texture 200, 3, 1
position object 200, 1000, 2000, 4000
scale object 200, 30000, 30000, 30000
` reset the directory
set dir ".."
` position the camera
position camera 801,19,202
` main program loop
do
` handle user input and show some stats
gosub userInput
gosub information
` get the height of the terrain at the current camera position
a# = get terrain ground height( 1, camera position x( ), camera position z( ) )
` now position the camera slightly above the terrain
position camera camera position x( ), a# + 3, camera position z()
` let the terrain handle some internal work
update terrain
` final screen update
sync
loop
userInput:
` simple mouse and keyboard movement
` move around with arrow keys
control camera using arrowkeys 0, g_fSpeed#, g_fTurn#
` store old camera angle
OldCamAngleY# = CameraAngleY#
OldCamAngleX# = CameraAngleX#
` store new camera angle
CameraAngleY# = wrapvalue ( CameraAngleY# + mousemovex ( ) * 0.4 )
CameraAngleX# = wrapvalue ( CameraAngleX# + mousemovey ( ) * 0.4 )
` rotate camera
yrotate camera curveangle ( CameraAngleY#, OldCamAngleY#, 24 )
xrotate camera curveangle ( CameraAngleX#, OldCamAngleX#, 24 )
` speed up movement
if inkey$ ( ) = "+"
if g_fSpeed# < 1000
g_fSpeed# = g_fSpeed# + 0.01
endif
endif
` slow down movement
if inkey$ ( ) = "-"
if g_fSpeed# > 0.002
g_fSpeed# = g_fSpeed# - 0.001
endif
endif
return
information:
` show some information
` start printing at top of screen
set cursor 0, 0
` show frame rate
print "FPS = " + str$ ( screen fps ( ) )
print ""
` current camera position
print ""
print "X = " + str$ ( camera position x ( ) )
print "Y = " + str$ ( camera position y ( ) )
print "Z = " + str$ ( camera position z ( ) )
print ""
` finally the polygon count
print "Polygon Count = " + str$ ( statistic ( 1 ) )
print ""
return
Thank you so much in advanced!