Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / can anyone....?

Author
Message
vulcan
18
Years of Service
User Offline
Joined: 5th Nov 2006
Location:
Posted: 6th Nov 2006 01:22
i am currently working on the tutorial for monster hunt

can anyone tell me how to display a message after you kill about five monsters and then you press enter then the game continues then after you kill about two another message pops up and so on
RUCCUS
20
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 6th Nov 2006 05:09
Complete the tutorial first, then move onto adapting the outcome to what you're looking for. Chances are by the end of the tutorial you'll have learnt how to accomplish what you're asking.

Your signature has been erased by a mod because it's larger than 600x120...
vulcan
18
Years of Service
User Offline
Joined: 5th Nov 2006
Location:
Posted: 9th Nov 2006 01:28
ok i got the tut done but i dont know if everything is in the right place. And the turning is messed up along wiht the shooting. I also don't have time to figure out how to display a message when one monster is killed then display a different message once the next monster is killed and so on, cuz i have to have it done tonight and i have other school projects i have to work on
so after i finished the tutorial, this is what i got

Sync On
Sync Rate 30
Hide mouse
Backdrop on
Set camera range 1,5000

Fog on
Fog distance 4000
Fog color RGB(128,128,128)
Color Backdrop RGB(128,128,128)

Rem make matrix
Make matrix 1,10000,10000,20,20

Rem texture matrix
Load image "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

Rem Load Target
Load object "idle.x",3
append Object "Walk.x",3,21

rem Make Gun
Make object cylinder 1,2
XRotate Object 1,90
Fix object pivot 1
Scale object 1,100,100,500
position object 1,0,-7,15
Lock object on 1

Rem Make bullet
Make Object Sphere 2,2
Hide Object 2

Load sound "crickets.wav",1
Loop sound 1

Load 3Dsound "fireball2.wav",2

Rem load particles
Load Image "fire.bmp",2
For x = 0 to 10
Make object plain x+10,5,5
Texture object x+10,2
Set object x+10,1,0,0
Ghost object on x+10
Next x

Rem intialize particle counter
Pn=10

rem Make Explosion
Make Object Sphere 30,20
texture object 30,2
ghost object on 30
Hide Object 30
Make Object Sphere 31,20
texture object 31,2
ghost object on 31
Hide Object 31
Load 3Dsound "Explode.wav",3

rem Make MonsterBullet
Make Object Sphere 102,2
texture object 102,2
Hide Object 102

rem Make Monster Explosion
Make Object Sphere 130,20
texture object 130,2
ghost object on 130
Hide Object 130
Make Object Sphere 131,20
texture object 131,2
ghost object on 131
Hide Object 131

rem load Monsterparticles
Load Image "fire.bmp",2
For x =100 to 110
Make object plain x+10,5,5
Texture object x+10,2
Set object x+10,1,0,0
Ghost object on x+10
Hide object x+10
Next x
MPn=110

Load 3Dsound "fireball2.wav",102
Load 3Dsound "Explode.wav",103

Gosub PlaceMonster
Gosub PlacePlayer

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#
mX#=rnd(10000)
mZ#=rnd(10000)
mY#= get ground height(1,mX#,mZ#)
If DecoCollide(mX#,mY#,mZ#) = 1
mX#=X#
mY#=Y#
mZ#=Z#
endif
Return

PlacePlayer:
While Sqrt((X# - mX#)^2 + (Y#+25 - mY#)^2 + (Z# - mZ#)^2)<1000
X#=rnd(10000)
Z#=rnd(10000)
Y#= get ground height(1,X#,Z#)
EndWhile
Position camera X#,Y#,Z#
X#=rnd(10000)
Z#=rnd(10000)
Y#= get ground height(1,X#,Z#)
If DecoCollide(X#,Y#,Z#) = 1
X#=mX#
Y#=mY#
Z#=mZ#
Endif

Return

rem make HUD
Make object Plain 200,1,1
position object 200,-2.7,1.9,4
Lock object on 200
ghost object on 200

Make object Plain 201,1,1
position object 201,2.7,1.9,4
Lock object on 201
ghost object on 201

rem Load and create hud bitmaps.
Load Bitmap "Radar.bmp",2
Create Bitmap 1,50,50

rem create decorative objects
load image "cottag02.bmp",300
t=300
For x = 1 to 9
For z = 1 to 9
Make object cube t,100
Scale object t,100,600,100
y = get ground height(1,x*1000,z*1000)
position object t,x*1000,y+275,z*1000
texture object t,300
scale object texture t,1,-6
inc t
next z
next x

Rem Main loop
Do
OldCamAngleY# = CameraAngleY#
OldCamAngleX# = CameraAngleX#
CameraAngleY# = WrapValue(CameraAngleY#+MousemoveX()*0.2)
CameraAngleX# = WrapValue(CameraAngleX#+MousemoveY()*0.2)

Rem Control input for camera
If Upkey()=1
XTest# = Newxvalue(X#,CameraAngleY#,10)
ZTest# = Newzvalue(Z#,CameraAngleY#,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(CameraAngleY#-180),10)
ZTest# = Newzvalue(Z#,Wrapvalue(CameraAngleY#-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(CameraAngleY#-90),10)
ZTest# = Newzvalue(Z#,Wrapvalue(CameraAngleY#-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(CameraAngleY#+90),10)
ZTest# = Newzvalue(Z#,Wrapvalue(CameraAngleY#+90),10)
If XTest#>0 and XTest#<10000 and ZTest#>0 and ZTest#<10000
X#=XTest#
Z#=ZTest#
Endif
Endif

Yrotate camera CurveAngle(CameraAngleY#,OldCamAngleY#,24)
Xrotate camera CurveAngle(CameraAngleX#,OldCamAngleX#,24)

Y# = Get ground height(1,X#,Z#)
Position Camera X#,Y#+50,Z#

if Mouseclick()=1 and BulletLife=0
Position object 2,X#,Y#+43,Z#
Set object to camera orientation 2
BulletLife =25
Show object 2
Endif
If BulletLife > 0
Dec BulletLife
Move object 2,20
If BulletLife = 0 then Hide object 2
Endif

Rem Rotate camera
if cAX#>270
if cAX#-270 > 90 then cAX#=270
else
if cAX# > 90 and cAX#-270<270 then cAX#=90
endif

YRotate camera CurveAngle(cAY#,oldcAY#,24)
XRotate camera CurveAngle(cAX#,oldcAX#,24)

Rem Position Listener
Position Listener X#,Y#+50,Z#
Rotate Listener 0,cameraAngleY#,0

Rem Shoot bullet
if Mouseclick()=1 and BulletLife=0
Position object 2,X#,Y#+43,Z#
Set object to camera orientation 2
BulletLife=25
show object 2
Loop sound 2
Endif

If BulletLife > 0 then Gosub ShootBullet
ShootBullet:
Dec BulletLife
Move object 2,10
bX#=Object position X(2)
bY#=Object position Y(2)
bZ#=Object position Z(2)
inc Pn
if Pn=21 then Pn=10
Scale object Pn,100,100,100
Position object Pn,bX#,bY#,bZ#
point object Pn,X#,Y#,Z#
Zrotate object Pn,rnd(180)
for x = 1 to 10
scale object int((Wrapvalue((Pn-9+x)*36))/36)+10,100+x*25,100+x*25,100+x*25
set cursor 10,10
next x
if bY# < Get Ground height(1,bX#,bZ#) then BulletLife=0
Position sound 2,bX#,bY#,bZ#
set cursor 10,10
if Sqrt((mX# - bX#)^2 + (mY#+25 - bY#)^2 + (mZ# - bZ#)^2) <20
print "hit hit hit hit hit hit hit hit"
BulletLife = 0
if DecoCollide(bX#,bY#,bZ#) = 1 then BulletLife = 0
Endif

if BulletLife = 0
Hide object 2
stop sound 2
for x=10 to 20
hide object x
next x
Explode = 20
endif
Return

if Mouseclick()=1 and Explode =0
if BulletLife<50
Position object 2,X#,Y#-7,Z#
Set object to camera orientation 2
BulletLife =120
show object 2
Loop sound 2
Endif
Endif

If Explode > 0 then Gosub ExplodeRocket
Rem Explode bullet
ExplodeRocket:
Position object 30,bX#,bY#,bZ#
Show object 30
Position object 31,bX#,bY#,bZ#
Show object 31
EScale=20*(30-Explode)
Scale object 30,EScale,EScale,EScale
Yrotate object 30,WrapValue(Explode*37)
Scale object 31,EScale/1.5,EScale/1.5,EScale/1.5
Yrotate object 31,WrapValue(359-Explode*37)
Dec Explode
If Explode = 0 then hide object 30: Hide object 31
If Explode=18
position sound 3,bX#,bY#,bZ#
play sound 3
endif
If Explode < 15 then position sound 3,X#,Y#,Z#
Return

If MonsterBulletLife > 0 then Gosub MonsterShootBullet
If MonsterExplode > 0
Gosub MonsterExplodeRocket
else
Gosub MonsterAI
endif
Rem Simple AI for guided monster missile
MonsterAI:

Point object 3,X#,Y#,Z#
PDist=Sqrt((mX# - X#)^2 + (mY#+25 - Y#)^2 + (mZ# - Z#)^2)
if PDist<1500
if MonsterBulletLife=0 or MonsterBulletLife < 500-PDist/10
Point object 3,X#,Y#-25,Z#
Position object 102,mX#,mY#+25,mZ#
Set object to object orientation 102,3
MonsterBulletLife =500
show object 102
Loop sound 102
Endif

endif
Return

Rem Shoot Monster bullet
MonsterShootBullet:

if DecoCollide(MbX#,MbY#,MbZ#) = 1
MonsterBulletLife = 0
BulletAvoidDeco = BulletAvoidDeco + 2
Endif

if MbY# < Get Ground height(1,MbX#,MbZ#)
MonsterBulletLife=0
ShootUp=3
if DecoCollide(MbX#,MbY#,MbZ#) = 1 then MonsterBulletLife = 0
Endif

Dec MonsterBulletLife
Move object 102,12
MbX#=Object position X(102)
MbY#=Object position Y(102)
MbZ#=Object position Z(102)
inc MPn
if MPn=121 then MPn=110
Scale object MPn,100,100,100
Position object MPn,MbX#,MbY#,MbZ#
Position sound 102,MbX#,MbY#,MbZ#
point object MPn,X#,Y#,Z#
Zrotate object MPn,rnd(180)
Show object MPn
for x = 1 to 10
scale object int((Wrapvalue((MPn-9+x)*36))/36)+110,100+x*25,100+x*25,100+x*25
next x
if MbY# < Get Ground height(1,MbX#,MbZ#) then MonsterBulletLife=0
Pdist=Sqrt((X# - MbX#)^2 + (Y#+25 - MbY#)^2 + (Z# - MbZ#)^2)
if Pdist<50
GoSub PlacePlayer
MonsterBulletLife = 0
endif

Rem guided missile
if Pdist <500 and Pdist>250 then Point object 102,X#,Y#,Z#
if Pdist < 100 then point object 102,X#,Y#,Z#
if MonsterBulletLife = 0
Hide object 102
stop sound 102
for x=110 to 120
hide object x
next x
MonsterExplode = 20
endif

Return

Rem Explode monster bullet
MonsterExplodeRocket:
Position object 130,MbX#,MbY#,MbZ#
Show object 130
Position object 131,MbX#,MbY#,MbZ#
Show object 131
EScale=20*(30-MonsterExplode)
Scale object 130,EScale,EScale,EScale
Yrotate object 130,WrapValue(MonsterExplode*37)
Scale object 131,EScale/1.5,EScale/1.5,EScale/1.5
Yrotate object 131,WrapValue(359-MonsterExplode*37)
Dec MonsterExplode
If MonsterExplode = 0 then hide object 130: Hide object 131
If MonsterExplode=18
position sound 103,X#,Y#,Z#
play sound 103
endif
If MonsterExplode < 15 then position sound 103,X#,Y#,Z#
Return

set cursor 550,20
print "MScore: ",MonsterScore
set cursor 550,40
print "PScore: ",PlayerScore

if Sqrt((mX# - bX#)^2 + (mY#+25 - bY#)^2 + (mZ# - bZ#)^2) <20
Gosub PlaceMonster
inc PlayerScore
MonsterBulletLife = 1
BulletLife=0
endif

Pdist=Sqrt((X# - MbX#)^2 + (Y#+25 - MbY#)^2 + (Z# - MbZ#)^2)
if Pdist<50
GoSub PlacePlayer
MonsterBulletLife = 0
inc MonsterScore
endif

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)

rem collision detection
if DecoCollide(X#,Y#,Z#) = 1
X#=oldX#
Y#=oldY#
Z#=oldZ#
Endif

Rem Simple AI for guided monster missile
MonsterAI2:
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
show object 102
Loop sound 102

Rem Play idle animation
Loop Object 3,0,20
Endif
Endif

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#)

Rem Check for Decoration collision
If DecoCollide(mX#,mY#,mZ#) = 1 and AvoidDeco = 0
mX# = OldmX#
mZ# = OldmZ#
mY# = OldmY#
AvoidDeco = 3
Endif
Endif

Return

Rem Refresh Screen
Sync
Loop

Rem check for collision with wall decorations
Function DecoCollide(X#,Y#,Z#)
for u = 1 to 9
for v = 1 to 9
if X#>u*1000-60
if X#<u*1000+60
if Z#>v*1000-60
if Z#<v*1000+60
if Y# < Get ground height(1,u*1000,v*1000)+575
Collide=1
Exitfunction Collide
endif
endif
endif
endif
endif
next v
next u
Collide=0
Endfunction Collide

Login to post a reply

Server time is: 2025-05-25 22:59:08
Your offset time is: 2025-05-25 22:59:08