I'm new to DarkBasic and I have found various examples and I have put them together and I have a question. I'm not resturning any errors but I have a question with the camera. I tried setting the range of the camera but it dosen't seem to work. My question is how can I get rid of the objects disapperaing? It seems that I can not see the other side of the world into I get close to it and I would like to turn that off so I can see everything. Code Attached...
`************************************************************************************************************** [Create The Camera Distance]
REMSTART
Create The Camera Distance
REMEND
`******************************************************************************************************************************************
REM Tell How Far The Camera Is Away From The Object [X]
cx#=1
REM Tell How High The Camera Is Away From The Object [Z]
cz#=1
`********************************************************************************************************** [END Create The Camera Distance]
`************************************************************************************************************************* [Set Up The Game]
REMSTART
Set Up The Game
REMEND
REM Turn The AutoCam Feature Off
AutoCam Off
REM Hide The Mouse
Hide Mouse
REM Turn The Sync On
Sync On
REM Set The Sync Rate
Sync Rate 0
`********************************************************************************************************************* [END Set Up The Game]
`************************************************************************************************************************** [Game Variables]
REMSTART
Game Variables
REMEND
Gun=1
ScreenFace=2
Bullet=3
Self=4
Ammunition=5
Ammo=1000
Forward=6
Enemy=7
EBullet=8
Health=9
REM Declare The Day
day=0
REM Rotation Of The Sun
srotate#=270
REM Rotation Of The Moon
mrotate#=90
`********************************************************************************************************************** [END Game Variables]
`************************************************************************************************************************* [Set Up The Game]
REMSTART
Set Up The Game
REMEND
REM Load The Game Images
GoSub LoadGameImages
REM Load The Game Models
GoSub LoadGameModels
REM Load The Game Sounds
GoSub LoadGameImages
REM Position The Game Objects
GoSub PositionGameObjects
REM Create And Texture The World
Gosub TextureWorld
REM Set Up The Sky
GoSub CreateSky
`********************************************************************************************************************* [END Set Up The Game]
make object box health,50,150,50
position object health,rnd(4000),75,rnd(4000)
make object sphere enemy,100
color object enemy,rgb(0,255,0)
position object enemy,rnd(4000),100,rnd(4000)
make object cylinder forward,1
scale object forward,100,100,25000
hide object forward
make object sphere 4,50
position object 4,200,100,200
`******************************************************************************************************************* [Set Up The Game World]
REMSTART
Set Up The Game World
REMEND
REM Texture For The Ground
Load Bitmap "Textures\Ground.bmp",1
REM Get The Image
Get Image 1,0,0,256,256
REM Delete The Bitmap
Delete Bitmap 1
REM Make The Game World
Make Matrix 1,4000,4000,60,60
REM Prepare To Texture The Matrix
Prepare matrix texture 1,1,1,1
REM Fill The Matrix
Fill matrix 1,0,1
REM Update The Matrix
Update Matrix 1
`*************************************************************************************************************** [END Set Up The Game World]
make object cylinder 1,2
color object gun,rgb(100,100,100)
`hide object gun
`xrotate object gun,90
`fix object pivot gun
scale object gun,100,100,500
`position object gun,0,-7,15
`lock object on gun
make object sphere 3,5
hide object bullet
color object bullet,rgb(255,0,0)
make object sphere 8,5
hide object ebullet
color object ebullet,rgb(255,0,0)
hide object ebullet
hide object self
`show object gun
make object box ammunition,50,150,50
color object ammunition,rgb(200,200,200)
position object ammunition,rnd(4000),75,rnd(4000)
color object health,rgb(200,100,100)
REM Start The Game
GoSub MainGame
REM Texture All Game Objects
GoSub TextureWorld
MainGame:
`***********************************************************[Main Game Loop]***********************************************************
Do
REM Control The Game Time
Gosub GameTime
REM Control The Game Clouds
Scroll Object Texture 10,0.0001,0.0
Scroll Object Texture 10,0.0,0.0001
if corr>99
for c=0 to 255 step 20
cls rgb(c,0,0)
if fog available()=1 then fog distance (c*5) : fog color (c*256*256)
sync
next c
corr=0
ammo=1000
kills=0
endif
ncpx#=object position x(self)
ncpy#=object position y(self)
ncpz#=object position z(self)
ehitu=object collision(self,0)
REM set object to object orientation enemy,self
move object enemy,-10
REMSTART
if dstoe<3000 and eshot=0
position object ebullet,object position x(enemy),object position y(enemy),object position z(enemy)
set object to object orientation enemy,self
rotate object ebullet,object angle x(enemy),object angle y(enemy),object angle z(enemy)
show object ebullet
eshot=1
endif
REMEND
if eshot=1
move object ebullet,-50
if ehitu=ebullet
corr=corr+20
hide object ebullet
eshot=0
endif
if dstoeb>3000
hide object ebullet
eshot=0
endif
endif
if ehitu=ammunition
position object ammunition,rnd(4000),75,rnd(4000)
ammo=ammo+50
endif
if ehitu=health
position object health,rnd(4000),75,rnd(4000)
corr=corr-5
endif
camx#=camera position x()
camy#=camera position y()
camz#=camera position z()
`dstoe=sqrt((object position x(enemy)-camx#)^2+(object position y(enemy)-camy#)^2+(object position z(enemy)-camz#)^2)
`dstoeb=sqrt((object position x(enemy)-object position x(ebullet))^2+(object position y(enemy)-object position y(ebullet))^2+(object position z(enemy)-object position z(ebullet))^2)
set cursor 0,0
if ammo<100 then ink rgb(150,0,0),1
REM print "Charges: ";ammo
if ammo<100 then ink rgb(255,255,255),1
if corr>90
ink rgb(150,0,0),1
endif
if corr>=0
REM print "Corruption: ";corr;"%"
endif
if corr<0
REM print "Encryption: ";abs(corr)/5;"Mb"
endif
if corr>90 then ink rgb(255,255,255),1
REM print "Viruses Deleted: ";kills
set cursor 0,200
REMSTART
print "Aim with mouse."
print "Shoot with left mouseclick."
print "Jump with right mouseclick."
print "Use ASDW or arrowkeys to move."
REMEND
ncxa#=camera angle x()
ncya#=camera angle y()
nibopx#=object position x(self)
nibopy#=object position y(self)
nibopz#=object position z(self)
position camera object position x(self),object position y(self),object position z(self)
rotate camera object angle x(self),object angle y(self),object angle z(self)
wvtx=object angle x(self)
wvty=object angle y(self)
wvtz=object angle z(self)
wcax=wrapvalue(wvtx)
wcay=wrapvalue(wvty)
wcaz=wrapvalue(wvtz)
rotate camera wrapvalue(cxa#),cya#,0
rotate object self,0,camera angle y(),0
position camera object position x(self),object position y(self),object position z(self)
`*************************************************************************************************************** [Player Movement Controls]
REMSTART
This Controls The Player Movement And Interaction
REMEND
`******************************************************************************************************************************************
REMSTART
If The [UP] Key Is Pressed
REMEND
if keystate(17)=1 or upkey()=1
x#=newxvalue(x#,cya#,16.0) : z#=newzvalue(z#,cya#,16.0)
endif
`******************************************************************************************************************************************
`******************************************************************************************************************************************
REMSTART
If The [DOWN] Key Is Pressed
REMEND
if keystate(31)=1 or downkey()=1
x#=newxvalue(x#,cya#,-16.0) : z#=newzvalue(z#,cya#,-16.0)
endif
`******************************************************************************************************************************************
`******************************************************************************************************************************************
REMSTART
If The [LEFT] Key Is Pressed
REMEND
if keystate(30)=1 or leftkey()=1
x#=newxvalue(x#,wrapvalue(cya#-90.0),20.0)
z#=newzvalue(z#,wrapvalue(cya#-90.0),20.0)
endif
`******************************************************************************************************************************************
`******************************************************************************************************************************************
REMSTART
If The [RIGHT] Key Is Pressed
REMEND
if keystate(32)=1 or rightkey()=1
x#=newxvalue(x#,wrapvalue(cya#+90.0),20.0)
z#=newzvalue(z#,wrapvalue(cya#+90.0),20.0)
endif
`******************************************************************************************************************************************
`******************************************************************************************************************************************
REMSTART
If The [UP] Key Is Pressed
REMEND
if jumpb=1
height#=height#-.7
endif
`******************************************************************************************************************************************
`******************************************************************************************************************************************
REMSTART
If The [MOUSE KEY 1] Key Is Pressed
REMEND
if mouseclick()=1 and dst=0 and ammo>0
ammo=ammo-1
shot=1
bdst=1
dst=1
show object bullet
position object bullet,camera position x(),camera position y(),camera position z()
rotate object bullet,camera angle x(),camera angle y(),camera angle z()
rotate object forward,object angle x(bullet),object angle y(bullet),object angle z(bullet)
position object forward,object position x(bullet),object position y(bullet),object position z(bullet)
endif
`******************************************************************************************************************************************
`******************************************************************************************************************************************
REMSTART
If The [MOUSE KEY 2] Key Is Pressed
REMEND
if mouseclick()=2 and ajump=1
jumpb=1
height#=15
endif
`******************************************************************************************************************************************
`*********************************************************************************************************** [END Player Movement Controls]
`************************************************************************************************************************* [Player Gravity]
REMSTART
This Controls The Player Gravity IF AND ONLY IF The Player Jumps
REMEND
if height#<-13 then height#=-13
if object position y(self)>100 then ajump=0 else ajump=1
position object self,object position x(self),object position y(self)+height#,object position z(self)
if object position y(self)<100
jumpb=0
height#=0
endif
`******************************************************************************************************************** [END Player Gravity]
`********************************************************************************************************* [Control's The Player's Bullet]
REMSTART
This Controls The Player Movement And Interaction
REMEND
if shot=1
if object collision(forward,enemy)=1
kills=kills+1
position object enemy,rnd(4000),100,rnd(4000)
endif
endif
`***************************************************************************************************** [END Control's The Player's Bullet]
if object position x(bullet)<0 or object position x(bullet)>4000 or object position z(bullet)>4000 or object position z(bullet)<0 or object position y(bullet)<0 or object position y(bullet)>1000
hide object bullet
dst=0
shot=0
endif
if shot=1
position object forward,object position x(bullet),object position y(bullet),object position z(bullet)
dst=dst+1
bdst=bdst+1
move object bullet,250
dst=dst+1
endif
cya#=wrapvalue(cya#+(mousemovex()/3.0))
cxa#=cxa#+(mousemovey()/3.0)
if cxa#<-45.0 then cxa#=-45.0
if cxa#>45.0 then cxa#=45.0
cx#=newxvalue(x#,cya#,sin(cxa#))
cz#=newzvalue(z#,cya#,sin(cxa#))
if cz#<0
cz#=ncpz#
z#=ncpz#
endif
if cz#>4000
cz#=ncpz#
z#=ncpz#
endif
if cx#<0
cx#=ncpx#
x#=ncpx#
endif
if cx#>4000
cx#=ncpx#
x#=ncpx#
endif
position object self,cx#,object position y(self)+height#,cz#
Loop Object 200,0,20
REM Control The People
GoSub ControlPeople
Sync
Loop
Return
`******************************************************[END Main Game Loop]***********************************************************
`*************************************************************************************************************************************
REMSTART
Load Game Images
REMEND
LoadGameImages:
REM Load The Sky Textures
Load Image "Textures\Clouds.JPG",300
Return
`*************************************************************************************************************************************
`*************************************************************************************************************************************
REMSTART
Load Game Models
REMEND
LoadGameModels:
REM Load A Police Officer
Load Object "Models\1\Traffic Wardenwalk.X", 200
REM Scale A Police Officer
Scale Object 200,300,300,300
Return
`*************************************************************************************************************************************
`*************************************************************************************************************************************
REMSTART
Load Game Sounds
REMEND
LoadGameSounds:
Return
`*************************************************************************************************************************************
`*************************************************************************************************************************************
REMSTART
Create And Texture The Game World
REMEND
TextureWorld:
REM Create The North Wall
Make Object Box 401,4000,4000,5
REM Postion The North Wall
Position Object 401,2000,0,4000
REM Create The East Wall
Make Object Box 402,5,4000,4000
REM Postion The East Wall
Position Object 402,4000,0,2000
REM Create The South Wall
Make Object Box 403,4000,4000,5
REM Postion The South Wall
Position Object 403,2000,0,0
REM Create The West Wall
Make Object Box 404,5,4000,4000
REM Position The West Wall
Position Object 404,0,0,2000
Return
`*************************************************************************************************************************************
`*************************************************************************************************************************************
REMSTART
Position Game Objects
REMEND
PositionGameObjects:
REM Declare Random X
RandomX = Rnd(3000)
REM Declare Random Y
RandomY = Rnd(3000)
REM Declare Random Z
RandomZ = Rnd(3000)
REM Position The Police Officer
Position Object 200,RandomX,0,RandomZ
Return
`*************************************************************************************************************************************
`*************************************************************************************************************************************
REMSTART
Create And Set Up The Camera
REMEND
CameraSetup:
REM Set Up The Camera Range
Set Camera Range 1,10000
Return
`*************************************************************************************************************************************
`*************************************************************************************************************************************
REMSTART
Control The Random People In The Map
REMEND
ControlPeople:
`*************************************************************************************************************************************
REM Declare The Police Officer
POLICEOFFICER1 = 200
POLICEOFFICER1x = Object position X(POLICEOFFICER1)
POLICEOFFICER1y = Object position Y(POLICEOFFICER1)
POLICEOFFICER1z = Object position Z(POLICEOFFICER1)
REM Declare A Way To Walk
POLICEOFFICE1DIRECTION = Rnd(4)
If POLICEOFFICE1DIRECTION = 1
REM Move Left
Position Object 200,POLICEOFFICER1x - 20,POLICEOFFICER1y,POLICEOFFICER1z
Else
If POLICEOFFICE1DIRECTION = 2
REM Move Right
Else
If POLICEOFFICE1DIRECTION = 3
REM Move Up
Else
If POLICEOFFICE1DIRECTION = 4
REM Move Down
Else
EndIf
EndIf
EndIf
EndIf
Return
`**************************************************************************************************************************************
`*************************************************************************************************************************************
`*************************************************************************************************************************************
REMSTART
Create And Set Up The Sky
REMEND
CreateSky:
REM Create The Sky
Make Object Box 10,4000,10,4000
REM Position The Sky
Position Object 10,2000,2000,2000
REM Texture The Sky
Texture Object 10,300
REM Create Another Light
make light 1 : set directional light 1,0,0,0
REM Color The Light
color light 1,rgb(0,0,50)
REM Make The Light
make light 2: set directional light 2,0,0,0
REM COlor The Light
color light 2,rgb(0,0,50)
Return
`*************************************************************************************************************************************
`*************************************************************************************************************************************
REMSTART
This Controls The (Real Time) Time
REMEND
GameTime:
`Time Speed / Rationale
`Change timespeed# to .03 for a reasonable time for real games. .530 is very fast and is for showing how the time works.
REM timespeed#=0.300
timespeed#=0.300
realtime#=realtime#+timespeed#
`Lights and Fog
fog color rgb(red#,green#,blue#)
`
color light 0,rgb(red#,green#,blue#)
set directional light 0,1,1,1
`Red
if rl=0
rl#=rl#-(timespeed#*0.30)
if rl#=<0 then rl#=0
endif
if rl=1
rl#=rl#+(timespeed#*0.18)
if rl#=>255 then rl#=255
endif
`Green
if gl=0
gl#=gl#-(timespeed#*0.35)
if gl#=<0 then gl#=0
endif
if gl=1
gl#=gl#+(timespeed#*0.16)
if gl#=>255 then gl#=255
endif
`Blue
if bl=0
bl#=bl#-(timespeed#*0.41)
if bl#=<50 then bl#=50
endif
if bl=1
bl#=bl#+(timespeed#*0.25)
if bl#=>255 then bl#=255
endif
`On the clock - Red
if oclock=>4 and oclock=<16 then rl=1
if oclock=>17 and oclock=<23 then rl=0
if oclock=>0 and oclock=<3 then rl=0
`On the clock - Green
if oclock=>5 and oclock=<17 then gl=1
if oclock=>18 and oclock=<23 then gl=0
if oclock=>0 and oclock=<4 then gl=0
`On the clock - Blue
if oclock=>0 and oclock=<3 then bl=0
if oclock=>6 and oclock=<18 then bl=1
if oclock=>19 and oclock=<23 then bl=0
`
if oclock=24 then oclock=0
if oclock=>0 and oclock=<11 then xm$="AM"
if oclock=>12 and oclock=<23 then xm$="PM"
`
if oclock=0 and dstop=0 then day=day+1 : dstop=1
if oclock>1 then dstop=0
`Denote Time
if realtime#=>0 and realtime#<10 then rt$="0"+str$(int(realtime#))
if realtime#>=10 and realtime#<60 then rt$=str$(int(realtime#))
if realtime#=>60 then oclock=oclock+1 : realtime#=0
if realtime#=0 then hr=hr+1
`Altering Variables
amb#=1+rl#*1.5
red#=rl#*1.5
green#=gl#*1.0
blue#=bl#*1.5
if red#=>255 then red#=255 : if red#=<0 then red#=0
if green#=>255 then green#=255 : if green#=<0 then green#=0
if blue#=>255 then blue#=255 : if blue#=<0 then blue#=0
`Ambient Control
if amb#=<20 then amb#=20
if amb#=>75 then amb#=75
set ambient light amb#
Return
`*************************************************************************************************************************************
`*************************************************************************************************************************************
REMSTART
This Controls The Movement Of The Sun And Moon
REMEND
rem This is where the moon and the sun rotate around the landscape
SAT_CONTROL:
rem Sun
REM 2500
swide#=2500
if oclock=>0 and oclock=<22
sunx#=swide#*cos(srotate#)
suny#=swide#*sin(srotate#)
sunz#=swide#*sin(srotate#)
position object Sun,sunx#+camera position x(),suny#+camera position y(),sunz#+camera position z()
suntime#=suntime#+timespeed#
srotate#=suntime#*(timespeed#/1.5)
srotate#=wrapvalue(srotate#)-75
endif
rem Sun's Light
`
color light 1,rgb(red#,green#/2.5,0)
set light to object position 1,Sun
point object Sun,cx#,cy#,cz#
set light to object orientation 1,Sun
`
if oclock=23
sunx#=swide#*cos(srotate#)
suny#=swide#*sin(srotate#)
sunz#=swide#*sin(srotate#)
position object Sun,sunx#+camera position x(),suny#+camera position y(),sunz#+camera position z()
suntime#=0
srotate#=suntime#*(timespeed#/1.5)
srotate#=wrapvalue(srotate#)-75
endif
rem Moon
mwide#=-2200
moonx#=mwide#*cos(mrotate#)
moony#=mwide#*sin(mrotate#)
moonz#=mwide#*sin(mrotate#)
position object Moon,moonx#+camera position x(),moony#+camera position y(),moonz#+camera position z()
moontime#=moontime#+timespeed#
mrotate#=moontime#*(timespeed#/1.15)
mrotate#=wrapvalue(mrotate#)+245
rem Moon's Light
`
color light 2,rgb(0,green#/5,blue#)
set light to object position 2,Moon
point object Moon,cx#,cy#,cz#
set light to object orientation 2,Moon
Return
`*************************************************************************************************************************************
- Your creativity is only limited by YOUR imagination.