Oh bloady thing!
again
rem Temple of Dead
rem Berry Bakker
rem FishSoft
Sync On
Sync Rate 30
Hide mouse
Backdrop on
Set camera range 1,5000
set global collision on
Fog on
Fog distance 4000
Fog color RGB(128,128,128)
load bitmap "E:\Mijn documenten\School Berry\lucht1.bmp",3
get image 3,0,0,256,256
delete bitmap 3
texture backdrop 3
Rem make matrix
Make matrix 1,10000,10000,20,20
Rem texture matrix
Load image "D:\program files\Dark Basic Software\Dark Basic\media\bitmaps\textures\real\floor\grass09.bmp",1
Prepare matrix texture 1,1,1,1
Fill matrix 1,0,1
rem Randomize the matrix
randomize matrix 1,125
X#=5000
Z#=5000
t=2000
For x = 1 to 9
For z = 1 to 9
load object "D:\program files\Dark Basic Software\Dark Basic\media\models\static\T\TREE5.X",t
Scale object t,10000,10000,10000
y = get ground height(1,x*1000,z*1000)
position object t,x*1000,y,z*1000
inc t
next z
next x
rem create player collision object and hide
make object box 100,100,400,100
set object collision on 100
hide object 100
rem Make handGun
load object "D:\program files\Dark Basic Software\Dark Basic\media\models\textured\weapons\HANDGUN2\HANDGUN2.X",1
XRotate Object 1,180
zrotate object 1,180
Fix object pivot 1
Scale object 1,1000,1000,1000
position object 1,10,-8,15
Lock object on 1
Rem Make handgunebullet
Make Object Sphere 2,2
Hide Object 2
rem make uzi
p#=-10
for t=4 to 5
load object "D:\program files\Dark Basic Software\Dark Basic\media\models\textured\weapons\GUN19\GUN19.X",t
xrotate object t,180
zrotate object t,180
fix object pivot t
scale object t,1000,1000,1000
position object t,p#,-8,15
lock object on t
inc p#,20
hide object t
next t
rem make uzibullets
for t=6 to 56
make object sphere t,2
next t
rem Make MonsterBullet
Make Object Sphere 102,2
Hide Object 102
rem make HUD
Make object Plain 200,1,1
position object 200,-2.7,1.9,4
Lock object on 200
Make object Plain 201,1,1
position object 201,2.7,1.9,4
Lock object on 201
rem Load and create hud bitmaps.
Load Bitmap "D:\program files\Dark Basic Software\Dark Basic\tutorials\Source\Radar.bmp",2
Create Bitmap 1,50,50
Rem Load Target
Load object "D:\program files\Dark Basic Software\Dark Basic\media\models\animated\hoverbot\idle.x",3
append Object "D:\program files\Dark Basic Software\Dark Basic\media\models\animated\hoverbot\walk.x",3,21
scale object 3,200,200,200
Gosub PlaceMonster
Gosub PlacePlayer
Load music "D:\program files\Dark Basic Software\Dark Basic\media\music\Action\Chronoscape.mid",1
Loop music 1
Load 3Dsound "D:\program files\Dark Basic Software\Dark Basic\media\sounds\weapons\shoot.wav",2
load sound "D:\program files\Dark Basic Software\Dark Basic\media\sounds\weapons\reload.wav",3
Load 3Dsound "D:\program files\Dark Basic Software\Dark Basic\media\sounds\weapons\shoot.wav",102
Load 3Dsound "D:\program files\Dark Basic Software\Dark Basic\media\sounds\weapons\reload.wav",103
Rem Main loop
Do
rem Store old positions
rem store original values
oldx# = x#
oldz# = z#
rem perform sliding collision
if collision>0
noCollision=0
rem slide perpendicular to the camera angle
x# = newxvalue(x#,wrapvalue(a#+90),2*distance)
z# = newzvalue(z#,wrapvalue(a#+90),2*distance)
position object 100,x#,-100,z#
rem test collision again to see if we went in the wrong direction
if object collision(100,0)>0
rem reset position back to the original and slide in other direction
x#=oldx#
z#=oldz#
x# = newxvalue(x#,wrapvalue(a#-90),2*distance)
z# = newzvalue(z#,wrapvalue(a#-90),2*distance)
endif
else
rem the smoothing code here can certainly be tweaked further
rem if anyone finds ways to improve it, please post your updates
rem if no collision for a while, camera follows player collision object
if noCollision>4
colx#=x#
colz#=z#
endif
rem smooth the camera movement
x#=curvevalue(colx#,x#,5.0)
z#=curvevalue(colz#,z#,5.0)
rem uncomment these to see how it looks without smoothing
` x#=x#
` z#=z#
rem "smoothly" position camera and gun
position camera x#,0,z#
` position object 1,x#,0,z#
` position object 2,x#,0,z#
endif
rem reset the collision flags
collision=0
inc noCollision
oldcaY# = caY#
oldcaX# = caX#
caY# = WrapValue(caY#+MousemoveX()*0.2)
caX# = WrapValue(caX#+MousemoveY()*0.2)
Rem Rotate camera
if cAX#>270
if cAX#-270 > 90 then cAX#=oldcaX#
else
if cAX# > 90 and cAX#-270<270 then cAX#=oldcaX#
endif
YRotate camera CurveAngle(cAY#,oldcAY#,24)
XRotate camera CurveAngle(cAX#,oldcAX#,24)
rem jumping
if (lower$(inkey$() )="c") and (Saut=0) and (labour=0) and (c=0) then c=1:saut=1:touch=1:Gosub Initialiser_Saut
if saut=1 then Gosub Gerer_Saut
Rem Control input for camera
If Upkey()=1
XTest# = Newxvalue(X#,caY#,10)
ZTest# = Newzvalue(Z#,caY#,10)
If XTest#>0 and XTest#<10000 and ZTest#>0 and ZTest#<10000
X#=XTest#
Z#=ZTest#
Endif
Endif
If Downkey()=1
XTest# = Newxvalue(X#,Wrapvalue(caY#-180),10)
ZTest# = Newzvalue(Z#,Wrapvalue(caY#-180),10)
If XTest#>0 and XTest#<10000 and ZTest#>0 and ZTest#<10000
X#=XTest#
Z#=ZTest#
Endif
Endif
If Leftkey()=1
XTest# = Newxvalue(X#,Wrapvalue(caY#-90),10)
ZTest# = Newzvalue(Z#,Wrapvalue(caY#-90),10)
If XTest#>0 and XTest#<10000 and ZTest#>0 and ZTest#<10000
X#=XTest#
Z#=ZTest#
Endif
Endif
If Rightkey()=1
XTest# = Newxvalue(X#,Wrapvalue(caY#+90),10)
ZTest# = Newzvalue(Z#,Wrapvalue(caY#+90),10)
If XTest#>0 and XTest#<10000 and ZTest#>0 and ZTest#<10000
X#=XTest#
Z#=ZTest#
Endif
Endif
rem perform movement on player collision object
position object 100,x#,y#-100,z#
rem test for initial collision
if object collision(100,0)
collision=2000
rem reset position variables back
x# = oldx#
z# = oldz#
rem position player collision object back to original position
position object 100,x#,y#-100,z#
rem store current cam and gun position
colx#=x#
colz#=z#
endif
Rem Position Listener
Position Listener X#,Y#+50,Z#
Rotate Listener 0,caY#,0
rem weapons cycler
if keystate(2)=1 then newgun=1
rem weapon 2
if keystate(3) then gosub gun_cycler_2
rem weapon gosub 1
if newgun=1 then gosub gun_cycler_1
rem weapon gosub 1
if newgun=2 then gosub gun_cycler_1_2
Rem Shoot bullet
if Mouseclick()=1 and BulletLife=0 and rotate=0 and bullets#>0
gunrotate=0
dec bullets#
Position object 2,X#,Y#+43,Z#
Set object to camera orientation 2
BulletLife=25
play sound 2
else
if rotate <0 and trotate=1 then inc rotate,5
if rotate >0 and trotate=1 then dec rotate,5
if rotate=5 or rotate=-5 then play sound 3
if rotate <>0 then trotate=1
if rotate =0 then trotate=0
rotate object 1,wrapvalue(rotate),0,wrapvalue(rotate)
Endif
If BulletLife > 0 and weapon=0 then gosub shootbullet
if bulletlife > 0 and weapon=1 then gosub shootuzibullet
If MonsterBulletLife > 0 then Gosub MonsterShootBullet
Gosub MonsterAI
Yrotate camera CurveAngle(caY#,oldcaY#,24)
Xrotate camera CurveAngle(caX#,oldcaX#,24)
Y# = Get ground height(1,X#,Z#)
Position Camera X#,Y#+50,Z#
rem make vizier
ink rgb(255,000,000),1
line 300,240,340,240
line 320,220,320,260
Rem make radar
Copy Bitmap 2,1
set current bitmap 1
ink rgb(0,0,255),rgb(0,0,0)
PRX#=X#/200
PRZ#=50-(Z#/200)
Circle PRX#,PRZ#,1
ink rgb(255,0,0),rgb(0,0,0)
MRX#=mX#/200
MRZ#=50-(mZ#/200)
Circle MRX#,MRZ#,1
Get image 200,0,0,50,50
set current bitmap 0
texture object 200,200
ink rgb(255,128,128),rgb(0,0,0)
set cursor 550,20
print "Health: ";playerhealth#
set cursor 550,40
print "Bullets: ";Bullets#
Rem Refresh Screen
Sync
Loop
rem functions
function Yvalue(x#,z#,ay#,L#)
zf#=l#*cos(ay#)
xf#=l#*sin(ay#)
yf#=get ground height(1,x#+xf#,z#+zf#)-get ground height(1,x#,z#)
lxzf#=sqrt(xf#^2+zf#^2)
ax#=(atan(yf#/lxzf#))
y2#=l#*sin(ax#)
lxz#=l#*cos(ax#)
x2#=lxz#*sin(ay#)
z2#=lxz#*cos(ay#)
endfunction y2#
rem subroutines
shootbullet:
if gunrotate=0 then dec rotate,15
if rotate<-50 then gunrotate=1
if gunrotate=1 then inc rotate,5
if rotate>0 then rotate=0
rotate object 1,wrapvalue(rotate),0,wrapvalue(rotate)
If BulletLife > 0
Dec BulletLife
Move object 2,20
bX#=Object position X(2)
bY#=Object position Y(2)
bZ#=Object position Z(2)
Position sound 2,bX#,bY#,bZ#
if bulletlife=15 then play sound 3
if bY# < Get Ground height(1,bX#,bZ#) then BulletLife=0
if Sqrt((mX# - bX#)^2 + (mY#+50 - bY#)^2 + (mZ# - bZ#)^2) <20
Gosub PlaceMonster
Inc PlayerScore
BulletLife=0
endif
endif
if bulletlife=0 then move object 2,0
return
Rem Simple AI for guided monster missile
MonsterAI:
Point object 3,X#,Y#,Z#
If AvoidDeco >0
mA# = Object Angle Y(3)
Dec AvoidDeco
Yrotate object 3,WrapValue(mA#+AvoidDeco*60)
endif
Rem Position Monster at new location
Position Object 3,mX#,mY#,mZ#
Rem check distance from player
PDist=Sqrt((mX# - X#)^2 + (mY#+25 - Y#)^2 + (mZ# - Z#)^2)
Rem If the player is within range shoot bullet
if PDist<1500
if MonsterBulletLife=0 or MonsterBulletLife < 500-Pdist/10
Point object 3,X#,Y#-25,Z#
If BulletAvoidDeco > 0
CornerAim = Rnd(1)
mA# = object angle Y(3)
if CornerAim = 0 then Yrotate Object 3,WrapValue(mA#+BulletAvoidDeco*10)
if CornerAim = 1 then Yrotate Object 3,WrapValue(mA#+BulletAvoidDeco*-16)
Dec BulletAvoidDeco
Endif
If ShootUp > 0
mA# = object angle X(3)
XRotate Object 3,WrapValue(mA#+ShootUp*-8)
Dec ShootUp
Endif
Position object 102,mX#,mY#+25,mZ#
Set object to object orientation 102,3
MonsterBulletLife =500
play sound 102
Rem Play idle animation
Loop Object 3,0,20
Endif
Endif
if pdist<3000
if PDist>1000
Rem Store old location
OldmX# = mX#
OldmZ# = mZ#
OldmY# = mY#
Rem Play walking animation
Loop Object 3,21,46
Rem Move monster
Move Object 3,7
Rem Get new position
mX# = Object Position X(3)
mZ# = Object Position Z(3)
mY# = Get Ground Height(1,mX#,mZ#)
Endif
Endif
Return
Rem Shoot Monster bullet
MonsterShootBullet:
Dec MonsterBulletLife
Move object 102,20
MbX#=Object position X(102)
MbY#=Object position Y(102)
MbZ#=Object position Z(102)
position sound 102,mbx#,mby#,mbz#
position sound 103,mx#,my#,mz#
if monsterbulletlife=200 then play sound 103
if MbY# < Get Ground height(1,MbX#,MbZ#)
MonsterBulletLife=0
ShootUp=3
endif
Pdist=Sqrt((X# - MbX#)^2 + (Y#+25 - MbY#)^2 + (Z# - MbZ#)^2)
if Pdist<50
Dec PlayerHealth#,5
if playerhealth# =< 0 then GoSub PlacePlayer
MonsterBulletLife = 0
endif
if monsterbulletlife=0 then move object 102,0
return
PlaceMonster:
mX#=X#
mZ#=Z#
mY#=Y#
While Sqrt((X# - MX#)^2 + (Y#+25 - MY#)^2 + (Z# - MZ#)^2)<1600
mX#=rnd(10000)
mZ#=rnd(10000)
mY#= get ground height(1,mX#,mZ#)
EndWhile
Position object 3,mX#,mY#,mZ#
Return
PlacePlayer:
PlayerHealth#=100
bullets#=100
x#=5000
Y#= get ground height(1,X#,Z#)
z#=9900
Position camera x#,Y#,z#
Return
weapon:
if change=1
if weapon=0
for t=4 to 5
show object 1
hide object t
next t
endif
if weapon=1
for t=4 to 5
show object t
hide object 1
next t
endif
endif
wait=0
return
shootuzibullet:
if gunrotate=0 then dec rotate,15
if rotate<-15 then gunrotate=1
if gunrotate=1 then inc rotate,10
if rotate>0 then rotate=0
rotate object 1,wrapvalue(rotate),0,wrapvalue(rotate)
for x=6 to 56
If BulletLife > 0
Dec BulletLife
obX#=Object position X(x)
obY#=Object position Y(x)
obZ#=Object position Z(x)
Move object x,30
bX#=Object position X(x)
bY#=Object position Y(x)
bZ#=Object position Z(x)
Position sound x,bX#,bY#,bZ#
if bY# < Get Ground height(1,bX#,bZ#) then BulletLife=0
if Sqrt((mX# - bX#)^2 + (mY#+50 - bY#)^2 + (mZ# - bZ#)^2) <20
Gosub PlaceMonster
Inc PlayerScore
BulletLife=0
endif
endif
if bulletlife=0 then move object x,0
next x
return
rem show gun 1
Gun_cycler_1:
rem rotate weapons not in use inwards
angle = 0
position camera x#,y#+50,z#
inc angle,5
Xrotate object 4,angle
Xrotate object 5,angle
sync
rem hide other weapons
if angle >170
hide object 4
hide object 5
newgun=2
endif
return
gun_cycler_1_2:
rem show new weapon to pull out
show object 1
rem now pull out weapon 1
angle = 100
inc angle,5
Xrotate object 1,wrapvalue(angle)
sync
if angle >360 then newgun=0
return : rem now return to main game loop
rem show gun 2
Gun_cycler_2:
rem rotate weapons not in use inwards
angle = 0
repeat
position camera x#,y#+50,z#
inc angle,5
Xrotate object 1,angle
sync
until angle > 170
rem hide other weapons
hide object 1
rem show new weapon to pull out
show object 4
show object 5
rem now pull out weapon 1
angle = 100
repeat
inc angle,5
Xrotate object 4,wrapvalue(angle)
Xrotate object 5,wrapvalue(angle)
sync
until angle > 360
return : rem now return to main game loop
Initialiser_Saut:
VitessYSaut#=Acc_Gravite#/4
VitessXZSaut#=500
SautTime#=Timer()
return
`***************************************************************************************************************
Gerer_Saut:
ay#=wrapvalue(ay#+sens1*90.0*((Timer()-SautTime#)/1000.0))
y#=y#+(vitessySaut#*((Timer()-SautTime#)/1000))
x#=newxvalue(x#,ay#,(vitessxzSaut#*sens2*((Timer()-SautTime#)/1000)))
z#=newzvalue(z#,ay#,(vitessxzSaut#*sens2*((Timer()-SautTime#)/1000)))
VitessYSaut#=VitessYSaut#-(Acc_Gravite#*(Timer()-SautTime#)/1000)
sauttime#=timer()
if y#<get ground height(1,x#,z#)+0
y#=get ground height(1,x#,z#)+0
MoveLastLoop=0
saut=0
endif
return
We're all Christ and we're all Hitler.We want Christ to win.What would he've done if he had advertisements, T.V. and newspapers?The miracle today is communication.So let's use it.-John Lennon '69