` #######################################################################
` DarkBasic Dungeon by Hubdule
` Shows huge dungeons
` (c) by Color Arts 2002
` #######################################################################
Do
Set Text to Bold
Set Cursor 215,10:Print "Under The Real World"
Set Cursor 250,20:Print "test version"
Set Text To normal
Set Cursor 0,40:Print "THIS GAME IS FOR TESTING ONLY! ///Press ENTER to play\\\"
Repeat
UNtil returnkey() : goto game:
Loop
game:
`set display mode 800,600,16
sync on
sync rate 0
hide mouse
load object "media\gun.x",1
XRotate Object 1,90
Fix object pivot 1
Scale object 1,1,1,100
position object 1,5,-7,10
Lock object on 1
`HELID
GunSnd=1 : load sound "media\gun.wav",GunSnd
MusicSnd=101 : load sound "media\ingame.wav",MusicSnd
loop sound MusicSnd : set sound volume MusicSnd,100
`CROSSHAIR
CrossHairImg=2 : load image "media\crosshair.bmp",CrossHairImg
sprite 1,320-16,240-16,CrossHairImg
set sprite 1,0,1
`BULLET
rem Control gun firing
if mouseclick()=1 and bullet=-50
BulletObj=3 : make object cube BulletObj,0.1
bullet=100
play sound GunSnd
position object BulletObj,camera position x(0),camera position y(0),camera position z(0)
rotate object BulletObj,camera angle x(0),camera angle y(0),0
set bsp object collision 2,BulletObj,0.1,1
move object BulletObj,0.2
endif
backcolor=rgb(0,0,0)
backdrop on
color backdrop backcolor
cls
` Attention ... This value is the size of the map ! change it to fit your map file
mapsize=64
dim map$(mapsize,mapsize)
maxcubes=16
cubesize=200
collisionstep=int(cubesize/10)
fog on
fog color backcolor
fog distance (int(maxcubes)*cubesize)
set camera range 1,(maxcubes*cubesize)
` Current map
loadmap("media/dungeon.map",mapsize)
autocam off
load image "media/wall2.jpg",1
load image "media/CYGRASS1.bmp",2
load image "media/wall.jpg",3
` Wall … you can change the walls to other objects J
for i=1 to maxcubes*maxcubes
make object cube 100+i,cubesize
` make object sphere 100+i,cubesize
` make object box 100+i,cubesize,cubesize*2,cubesize
` make object cone 100+i,cubesize
` make object cylinder 100+i,cubesize+((cubesize/100)*10)
texture object 100+i,1
next i
` floor
for i=1 to maxcubes*maxcubes
make object plain 10000+i,cubesize,cubesize
rotate object 10000+i,90,0,0
texture object 10000+i,2
next i
` ceiling
for i=1 to maxcubes*maxcubes
make object plain 20000+i,cubesize,cubesize
rotate object 20000+i,270,0,0
texture object 20000+i,3
next i
set ambient light 30
make light 1
make light 2
set point light 1,0,0,0
set spot light 2,45,90
color light 2,RGB(252,216,141)
color light 1,RGB(236,182,100)
color light 0,RGB(0,0,0)
` Search startpoint
for z=1 to mapsize
for x=1 to mapsize
if map$(x,z)="O"
cx=x*cubesize
cz=z*cubesize
endif
if map$(x,z)="U"
ex=x
ez=z
endif
next x
next zd
position camera cx,0,cz
oldpositionx#=camera position x()
oldpositionz#=camera position z()
randomize timer()
cls
do
if downkey()= then move camera maxcubes
if upkey()= then move camera maxcubes*(-1)
ry#=wrapvalue(ry#+mousemovex())
rotate camera rx#,ry#,0
cx#=int(camera position x()/cubesize)-int(maxcubes/2)
cz#=int(camera position z()/cubesize)-int(maxcubes/2)
tx#=camera position x()
tz#=camera position z()
zzz=0
for zz=1 to maxcubes
for xx=1 to maxcubes
zzz=zzz+1
curposx=int(cx#)+xx
curposz=int(cz#)+zz
if curposx<=1 then curposx=1
if curposx>=mapsize then curposx=mapsize
if curposz<=1 then curposz=1
if curposz>=mapsize then curposz=mapsize
` wall
if map$(int(curposx),int(curposz))="#" or map$(int(curposx),int(curposz))="S"
show object 100+zzz
position object 100+zzz,curposx*cubesize,0.0,curposz*cubesize
` Collisiondetection
if map$(int(curposx),int(curposz))="#"
if tx#>=((curposx*cubesize)-(cubesize/2))-collisionstep and tx#<=((curposx*cubesize)+(cubesize/2))+collisionstep and tz#>=((curposz*cubesize)-(cubesize/2))-collisionstep and tz#<=((curposz*cubesize)+(cubesize/2))+collisionstep
position camera oldpositionx#,camera position y(),oldpositionz#
oldpositionx#=camera position x()
oldpositionz#=camera position z()
endif
endif
else
hide object 100+zzz
endif
` floor
if map$(int(curposx),int(curposz))=":" or map$(int(curposx),int(curposz))="D" or map$(int(curposx),int(curposz))="S" or map$(int(curposx),int(curposz))="T"
show object 10000+zzz
position object 10000+zzz,curposx*cubesize,(cubesize/2)*(-1),curposz*cubesize
else
hide object 10000+zzz
endif
` ceiling
if map$(int(curposx),int(curposz))=":" or map$(int(curposx),int(curposz))="D" or map$(int(curposx),int(curposz))="S" or map$(int(curposx),int(curposz))="T"
show object 20000+zzz
position object 20000+zzz,curposx*cubesize,(cubesize/2),curposz*cubesize
else
hide object 20000+zzz
endif
next xx#
next yy#
oldpositionx#=camera position x()
oldpositionz#=camera position z()
position light 1,camera position x(),camera position y(),camera position z()
position light 2,camera position x(),camera position y(),camera position z()
color light 1,RGB(200+int(rnd(50)-25),120,60)
rotate light 2,camera angle x(),camera angle y(),camera angle z()
sync
loop
function loadmap(filename$,size)
open to read 1,filename$
for y=1 to size
for x=1 to size
read byte 1,tmp
map$(x,y)=chr$(tmp)
next x
next y
close file 1
endfunction
Function Make_Bullet()
If mouseclick()-<>1 Then ExitFunction
If Timer()-LastTime<1000 Then ExitFunction
LastTime=Timer()
For i = 101 to 200
if Object Exist(i)=0 Then Exit
Next i
If i>200 then exitfunction
Make Object Sphere i,1,6,6
Position Object i,Camera Position X(),Camera Position Y(),Camera Position Z()
Set Object To Camera Orientation i
Move Object Right i,5
EndFunction
Function Move_Bullet()
For i = 101 to 200
For j = 1 to 5
If Object Exist(i)=0 Then Exit
Move Object i,1
c=Object Collision(i,0)
If c>0
Position Object c,Rnd(2000)-1000,10,Rnd(2000)-1000
Delete Object i
Endif
Next j
If Object Exist(i)
Scale Object i,100,100,101
If Object Size Z(i)>2 Then Delete Object i
Endif
Next i
EndFunction