This is the whole runnable Coda (as long as one has physics)
I still need to work on the velocity and collision code to prevent tunneling but more or less in the end i will have some decent template code.
REM Project: Vnet
REM Created: 5/22/2007 11:37:17 PM
rem Set-Up Display ------------------------
if check display mode(1024,768,32)=1 rem --
set display mode 1024,768,32 rem ---------
endif rem ---------------------------------
temp = make vector3(1)
` Start physics in our program
phy start
` turn sync rate on
sync on
sync rate 60
autocam off
`hide mouse
`----------Set different variables----------------------------
characterspeed = 50
load image "Image\grass.jpg",1
make object box 1, 1000, 50, 1000
position object 1,500,-25,500
texture object 1,1
scale object texture 1,100,100
Set object texture 1,1,1
` create a static rigid body box to represent the ground
phy make rigid body static box 1
`Create Surrounding wall (barricade off the edge of the world)
make object box 2,50,50,1000
make object box 3,50,50,1000
make object box 4,1000,50,50
make object box 5,1000,50,50
position object 2,1000,25,500
position object 3,0,25,500
position object 4,500,25,1000
position object 5,500,25,0
` Make the world wall solid with physX
for i = 2 to 5
phy make rigid body static box i
next i
` Texture your wall and scale texture to look decent
load image "Image\brick.bmp",2
for i = 2 to 5
texture object i,2
Scale object texture i,100,10
next i
` Make cube and convert to character controller to be ourplayer object
Make object cube 6, 10
position object 6, 500, 30, 400
phy make box character controller 6, 500, 30, 400, 10, 10, 10, 1, 1.5, 45
`hide object 6
load image "Image\metal.jpg",3,1
`make memblock 1,1
` Misc object for better idea of you movement
cubexpos=500
for a = 7 to 17
make object cube a,10
cubexpos=cubexpos+10.1
position object a,cubexpos,5,500
texture object a,2
phy make rigid body dynamic box a
next a
cubexpos=500
for a = 18 to 27
make object cube a,10
cubexpos=cubexpos+10.1
position object a,cubexpos,16,500
texture object a,2
phy make rigid body dynamic box a
next a
cubexpos=500
for a = 28 to 37
make object cube a,10
cubexpos=cubexpos+10.1
position object a,cubexpos,26,500
texture object a,2
phy make rigid body dynamic box a
next a
cubexpos=500
for a = 48 to 50
make object cube a,10
cubexpos=cubexpos+10.1
position object a,cubexpos,36,500
texture object a,2
phy make rigid body dynamic box a
next a
load image "Image\Crosshair.png",4,1
sprite 1,screen width()/2,screen height()/2,4
hide sprite 1
`---------- Main Loop ---------------------------------------------------------
do
gosub user_control
framerate_display()
gosub projectile_control
phy update
sync
loop
end
`~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
`========================================================================
`========================================================================
`===== SubRoutines =====
`========================================================================
`========================================================================
projectile_control:
if controlkey() = 1
show sprite 1
else
hide sprite 1
endif
if mouseclick() = 1
phy set continuous cd 1.0
If Waittime = 0
Waittime = 30
projectileID = GetNextFreeObj()
angy# = camera angle y()+4.5
angx# = -camera angle X()-2
make object sphere projectileID,2:hide object projectileID
color object projectileID,rgb (255, 100, 100)
position object projectileID,camera position x(),camera position y()-1,camera position z()
yrotate object projectileID,-camera angle y(0)
phy make rigid body dynamic sphere projectileID
` phy set rigid body linear momentum projectileID, 1000*sin(angy#)*cos(angx#),1000*sin(angx#),1000*cos(angy#)*cos(angx#)
phy set rigid body linear velocity projectileID, 200*sin(angy#)*cos(angx#),200*sin(angx#),200*cos(angy#)*cos(angx#)
phy set rigid body mass projectileID,9000
show object projectileID
ghost object on projectileID
endif
endif
if Waittime > 0
dec Waittime
endif
return
user_control:
position camera object position x ( 6 ), object position y ( 6 )+20, object position z ( 6 )
rotate camera object angle x ( 6 ), object angle y ( 6 ), object angle z ( 6 )
OldCamAngleY# = CameraAngleY#
OldCamAngleX# = CameraAngleX#
CameraAngleY# = wrapvalue ( CameraAngleY# + mousemovex ( ) * 0.4 )
CameraAngleX# = wrapvalue ( CameraAngleX# + mousemovey ( ) * 0.4 )
yrotate object 6, curveangle ( CameraAngleY#, OldCamAngleY#, 24 )
xrotate object 6, curveangle ( CameraAngleX#, OldCamAngleX#, 24 )
key = 0
if upkey ( )
key = 1
phy move character controller 6, CharacterSpeed
endif
if downkey ( )
key = 1
phy move character controller 6, -CharacterSpeed
endif
return
`========================================================================
`========================================================================
`===== Functions =====
`========================================================================
`========================================================================
Function framerate_display()
text 20,screen height()-40,desc$
fps$="DBPro Fps: "+str$(screen fps())
XYZCAMERA$="Camera XYZ ANGLE:"+str$(Camera Angle X())+","+str$(Camera Angle Y())+","+str$(Camera Angle z())
Current_Object_Number$ = str$(GetNextFreeObj())
text screen width()-20-text width(fps$),screen height()-40,fps$
text screen width()-40-text width(XYZCAMERA$),screen height()-80,XYZCAMERA$
text screen width()-60-text width(Current_Object_Number$),screen height()-120,Current_Object_Number$
EndFunction
function GetNextFreeObj()
obj = 1
while object exist(obj) = 1
inc obj,1
endwhile
endfunction obj
Attached is the required media<Of course you can change that in code or copy your own over)
Here I am But am not here, there you are not really there.