Here is the code everybody. Feel free to use and expand upon it in your own projects. Sorry I wasn't able to post this code in color (as it would appear in DBP). I know this would make this alot easier for you to examine. If someone could let me know how to do this for future posts, I would be greatful.
Rem Project: QuadrantHouseWalkthrough
Rem Created: Friday, June 22, 2012
Rem ***** Main Source File *****
`Declare Global Arrays
Global Dim ObjectArray(0) `Will reference objects to be manipulated by PlayerSelectItems() Not used for now
Global Dim MeshArray(0) `Mesh numbers associated with ObjectArray() Not used for now
Global Dim ShadowArray(0) `Will reference objects which will have shadowshading affected by UpdateShadows() Not used for now
`Define Types
Type ObjectShadows `This type mirrors the properties found in DBP command Set Shadow Shading ON
ObjectNo As Integer
PosX As Float
PosY As Float
PosZ As Float
MeshNo As Integer
Range As Integer
Shader As Boolean
EndType
`More Globals
Global shadowobject As ObjectShadows `Used in UpdateShadows()
Global cursorobj As ObjectShadows `Used in PlayerSelectItems() `
Global time# = 6.0 `Used in CloudTime()
Global ScreenFileVal = 6 `Used in PlayerMove() for getting images and is set to 6 to bypass images 1 to 5 which are to be loaded before hand
Global SyncRateDefault = 60 `Default Sync Rate value
Global Pictures$ = "Pictures" `Pictures folder
Global Path$ `Current path being used
Path$ = Get Dir$()
CD Path$
If Path Exist(Path$+Pictures$) = 0
Make Directory Pictures$
EndIf
`Set Global Shadow Color 0,0,0,70 `Not used for now
SetUpScreen() `Initialize screen settings
`Code that comes with Dark Clouds...I only modified the image numbers associated with the images to be loaded
rem Please wait
set text font "verdana" : s$="generating clouds...please wait"
center text screen width()/2,screen height()/2,s$ : sync
` move into the media directory
CD "Media"
load image "sunFlare.png",2
load image "Moon.png",3
load image "Rain.jpg",4
load image "Cirrus.jpg",5
rem init app at 60fps
sync on : sync rate SyncRateDefault
rem half-fill the sky with clouds
dc set cloudy 0.5
rem add a high-altitude cloud layer
dc set cirrus clouds 0.5
dc set cirrus image 5
rem clouds at 3 km
dc set cloud height 8
rem set sky brightness to 1
brightness#=1.0
dc set brightness brightness#
rem adjust brightness based on time of day
dc set auto brightness 1
rem set wind to 30 mph at 270 degrees (heading west)
dc set wind 30,270
rem init with texture number 1, and number of keyframes per hour
dc init 1,2
rem modify rayleigh scattering(optional) default: 7,11,24
dc set scattering 7,11,24
rem a slightly yellow sun:
dc set sun color 1.0,1.0,0.9
rem the update command creates the cloud texture
dc update time#
rem show texture 1 as the backdrop
Texture Backdrop 1
rem draw the sun
dc set sun image 2,0.2
rem draw the moon - three times!
dc set planet image 1,3,0.2,1
dc set planet direction 1,0.0,0.2,1.0
dc set planet image 2,3,0.15,1
dc set planet direction 2,0.9,0.4,-0.5
dc set planet image 3,3,0.05,1
dc set planet direction 3,0.9,0.4,0.5
rem create rain (rain will only appear when clouds are heavy)
dc set rain 1,1
dc set rain image 4
`initialize physics engine
phy start
CameraSetup() `Creates,sets position and range of user camera
SetLights() `Point light will be attached to camera in LightControls()
LoadObjects() `Loads building model and it's invisible 'bounding box' model
`return to main directory
CD ".."
`create our box controller
make object box 3, 5, 20, 5
position object 3,0,190,140
phy make box character controller 3,0,190,140, 5, 20, 5, 1, 30, 45.0
hide object 3
rem Main loop
do
PlayerMove()
Wait 200
PlayerSelectItems()
Wait 200
If EscapeKey() = 1
End
ENDIF
rem update screen
sync
rem end loop
loop
Function CloudTime()
rem step through the day at 20 times speed; 24 hours, 60 minutes, 60 seconds.
time#=time#+20.0/(24.0*60.0*60.0)
rem update clouds
dc update time#
sync
ENDFUNCTION
Function SetUpScreen()
Set Display Mode 640,480,32
Set Window Position 0,0
Set Window Layout 1,1,1
Set Window Title "QuadrantHouseWalkthrough"
If EscapeKey() = 1
End
ENDIf
ENDFUNCTION
Function CameraSetup()
AutoCam Off
Position Camera 0,190,140
Set Camera Range 1,4000
Sync
ENDFUNCTION
Function SetLights()
Make Light 1
Point Light 1,0,60,0
Set Light Range 1,500
Color Light 1,RGB(255,255,255)
sync
ENDFUNCTION
Function LoadObjects()
Load Object "QHouseMain.x",1
Position Object 1,0,0,0
phy make rigid body static mesh 1
Load Object "QHouseBoundingBox.x",2
Position Object 2,0,0,0
phy make rigid body static mesh 2
hide object 2
Load Object "QHouseBeams.x",4
Position Object 4,0,0,0
phy make rigid body static mesh 4
Load Object "QHouseGlass.x",5
Position Object 5,0,0,0
`Set Image Colorkey 248,251,255 `Color of the glass object
Set Object Transparency 5,2 `Can't seem to get the glass object transparent
phy make rigid body static mesh 5
set normalization on
sync
EndFunction
Function LightControls()
lightnum = 1
LightMax = 1000
LightMin = 10
LightRange = 500
x = Camera Position X()
y = Camera Position Y()
z = Camera Position Z()
Position Light lightnum,x,y,z
While MouseClick() = 1
Inc LightRange,10
Set Light Range 1,LightRange
If LightRange > LightMax
Set Light Range 1,LightMax
EndIF
Sync
ENDWhile
While MouseClick() = 2
Dec LightRange,10
Set Light Range 1,LightRange
If LightRange < LightMin
Set Light Range 1,LightMin
EndIf
Sync
ENDWhile
ENDFUNCTION
Function PlayerSelectItems() `Gives Player control of the cursor (derived from DBP tutorials)
Show Mouse
Do
CloudTime()
LightControls()
if mouseclick()=0 then pickmode=0 : cursorobj.ObjectNo=0
mclick=mouseclick()
if mclick>0
if pickmode=0
cursorobj.ObjectNo=pick object(mousex(),mousey(),2,1440)
if cursorobj.ObjectNo>0
pickmode=mclick
pickdistance#=get pick distance()
pickfromx#=get pick vector x()
pickfromy#=get pick vector y()
pickfromz#=get pick vector z()
if pickmode=1
// EZro_FindOffsetFromPoint 0,0,0
// cursorobj.PosX = EZro_GetOffsetX()
// cursorobj.PosY = EZro_GetOffsetY()
// cursorobj.PosZ = EZro_GetOffsetZ()
`Print "Actual Object X: ",cursorobj.PosX,"Actual Object Y: ",cursorobj.PosY,"Actual Object Z: ",cursorobj.PosZ
objx#=object position x(cursorobj.ObjectNo)
objy#=object position y(cursorobj.ObjectNo)
objz#=object position z(cursorobj.ObjectNo)
else
objx#=object angle x(cursorobj.ObjectNo)
objy#=object angle y(cursorobj.ObjectNo)
objz#=object angle z(cursorobj.ObjectNo)
pickdiffx#=mousemovey() : pickdiffx#=0
pickdiffy#=mousemovex() : pickdiffy#=0
endif
else
highlightobj=0
endif
endif
if pickmode>0
if pickmode=1
pick screen mousex(),mousey(),pickdistance#
picktox#=get pick vector x()
picktoy#=get pick vector y()
picktoz#=get pick vector z()
pickdiffx#=picktox#-pickfromx#
pickdiffy#=picktoy#-pickfromy#
pickdiffz#=picktoz#-pickfromz#
grid=0
if grid=1
pickdiffx#=int(pickdiffx#/5)*5
pickdiffy#=int(pickdiffy#/5)*5
pickdiffz#=int(pickdiffz#/5)*5
endif
`Start wheel code here (derived from DBP user James H)
unit=1
mz=mousez()/30
mmz=mousemovez()/30
if mmz<>0
newunit=unit*mmz
else
newunit=0
endif
adjustvalue = 30
noadjust=0
if finalpos+newunit=>adjustvalue then finalpos=adjustvalue : noadjust=1
if finalpos+newunit=<-adjustvalue then finalpos=-adjustvalue : noadjust=1
if noadjust=0 then finalpos=finalpos+newunit
`End wheel code here
If Object collision (cursorobj.ObjectNo,cursorobj.ObjectNo) = 0
x# = get object collision X()
y# = get object collision Y()
z# = get object collision Z()
position object cursorobj.ObjectNo,object position x(cursorobj.ObjectNo) + x#,object position y(cursorobj.ObjectNo) + y#,object position z(cursorobj.ObjectNo) + z# + finalpos
Else
position object cursorobj.ObjectNo,objx#+pickdiffx#,objy#+pickdiffy#,objz#+pickdiffz# + finalpos
EndIf
else
pickdiffx#=pickdiffx#+mousemovey()
pickdiffy#=pickdiffy#+mousemovex()
grid=0
if grid=1
tpickdiffx#=int(pickdiffx#/22.5)*22.5
tpickdiffy#=int(pickdiffy#/22.5)*22.5
else
tpickdiffx#=pickdiffx#
tpickdiffy#=pickdiffy#
endif
rotate object cursorobj.ObjectNo,wrapvalue(objx#-tpickdiffx#),wrapvalue(objy#-tpickdiffy#),objz#
endif
endif
endif
If MouseClick() = 3
ExitFunction
EndIf
sync
Loop
ENDFUNCTION
Function PlayerMove()
Hide Mouse `Hide mouse cursor
Do
If inkey$() = "p"
get image ScreenFileVal,0,0,screen width(),screen height(),1
TakeScreenShot(ScreenFileVal)
Inc ScreenFileVal,1
EndIf
CloudTime()
LightControls()
`Start wheel code here (derived from DBP user John H)
unit=1
mz=mousez()/30
mmz=mousemovez()/30
if mmz<>0
newunit=unit*mmz
else
newunit=0
endif
adjustvalue = 30
noadjust=0
if finalpos+newunit=>adjustvalue then finalpos=adjustvalue : noadjust=1
if finalpos+newunit=<-adjustvalue then finalpos=-adjustvalue : noadjust=1
if noadjust=0 then finalpos=finalpos+newunit
`End wheel code here
`Dark Physics FPSC code sample that I slightly modified
`rotate and position the camera based on the box controller
position camera object position x ( 3 ), object position y ( 3 ) + 30, object position z ( 3 )
rotate camera object angle x ( 3 ), object angle y ( 3 ), object angle z ( 3 )
OldCamAngleY# = CameraAngleY#
OldCamAngleX# = CameraAngleX#
CameraAngleY# = wrapvalue ( CameraAngleY# + mousemovex ( ) * 0.1 )
CameraAngleX# = CameraAngleX# + mousemovey ( ) * 0.1
FinalValueY# = (curveangle (CameraAngleY#,OldCamAngleY#, 6))
FinalValueX# = (curveangle (CameraAngleX#,OldCamAngleX#, 6))
WrapAngle = 45 `This is more of a limiting angle both positive and negative along the x-axis
If CameraAngleX# > WrapAngle
CameraAngleX# = WrapAngle
EndIF
IF CameraAngleX# < -WrapAngle
CameraAngleX# = -WrapAngle
EndIf
If CameraAngle# >= -WrapAngle And CameraAngleX# <= WrapAngle
xrotate object 3, FinalValueX#
EndIf
yrotate object 3, FinalValueY#
key = 0
if finalpos > 0
key = 1
phy move character controller 3, 260.0 + finalpos
endif
if finalpos < 0
key = 1
phy move character controller 3, -260.0 - finalpos
endif
if finalpos = 0
phy move character controller 3, 0.0
endif
`Dark Physics FPSC code sample end
`UpdateShadows()
If (MouseClick() = 4)
finalpos = 0
ENDIF
`Make sure mouse position stays centered within window
Position Mouse Screen Width()/2,Screen Height()/2
If (MouseClick() = 3)
ExitFunction
EndIf
`update physics
phy update
Sync
Loop
ENDFUNCTION
Function UpdateShadows()`Function I created to turn on/off shadows of individual objects, based on camera distance from those objects. Not used for now
ShadowBleed = -1400 `This variable means the distance from a given object with shadow shading turned on, in which the shadows appear through an object (bleeding or visual artifacts)
`when it should otherwise be hidden by it
Set Cursor 0,0
`Print "Total objects shadowed is ",Array Count (ShadowArray(0))
For c = 1 To Array Count (ShadowArray(0))
If Camera Position Z() <> Object Position Z(shadowobject.ObjectNo)
`Print Camera Position Z(), ",", Object Position Z(shadowobject.ObjectNo), "Shadow Range: ",shadowobject.Range
If Camera Position Z() < ShadowBleed Or Camera Position Z() > ABS (Shadowbleed)
Set Shadow Shading Off shadowobject.ObjectNo
`Print "Shadow Shading for object ",shadowobject.ObjectNo," turned off."
Else
Set Shadow Shading On shadowobject.ObjectNo,shadowobject.MeshNo,shadowobject.Range,shadowobject.Shader
`Print "Shadow Shading for object ",shadowobject.ObjectNo," turned on."
EndIf
EndIf
NEXT c
`EndIf
Sync
ENDFUNCTION
Function TakeScreenShot(img as integer) `Slightly modified code (from DBP user enderleit)
imgFileNo = 0
found as boolean
found = 0
CD Pictures$
` Find an available number for the screenshot file.
while found = 0
if file exist("ScreenShot"+str$(imgFileNo)+".bmp") = 0
found = 1
else
inc imgFileNo, 1
endif
endwhile
` Save the screenshot.
save image "ScreenShot"+str$(imgFileNo)+".bmp", img
Wait 100
CD Path$
EndFunction
As mentioned in my previous post, the problem error message that I have occurs when the program attempts to find the Media folder. CD "Media". If someone could offer any advice on how to correct this or spot any additional problems that could be adjusted, please let me know. I'll be looking forward to your replies. Thank You