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.

Newcomers DBPro Corner / Something wont work!! Help me!!!

Author
Message
Dark_Programmer
21
Years of Service
User Offline
Joined: 10th Dec 2002
Location:
Posted: 11th Dec 2002 02:32
Ok, i made the tutorial on 3d game making with the game project and all that stuff... And now i want to enhance it
by some little things; first, put those scorpions used for the room game for ennemies; second: make a better ai for them and make them walk to me if they see me; third enhance the textures for eveything. Step three is completed. Im at the state that i have to do the ennemies die when i shoot them. I added tyhe portion of the code that i composed for that and i keep getting a "Nesting error" message. Someone help me!!!

Heres the code:

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 bullet
Load image "C:\Program Files\Dark Basic Software\bullet.bmp",10
Make Object Sphere 2,0.45
Texture object 2,10
Hide object 2






Rem intialize particle counter
Pn=10



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

Rem texture matrix
Load image "C:\Program Files\Dark Basic Software\stoney02.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 make scorpions

for scorploop = 666 to 700
Load object "D:\Games\DarkBasic\Myproj\Room\obj\ScorpWalk.x",scorploop


scorpY# = int(rnd(10000))
scorpZ# = int(rnd(10000))
scorpX# = Get ground height(1,scorpX#,scorpZ#)

loop object scorploop
position object scorploop, scorpY#,scorpX#+270,scorpZ#
next scorploop

rem Make Gun
Load image "C:\Program Files\Dark Basic Software\metal.bmp",3

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
texture object 1,3
Lock object on 1


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








Rem Shoot


If mouseclick()=1
Load 3Dsound "C:\Program Files\Dark Basic Software\cannon.wav",12
play sound 12
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
bX#=Object position X(2)
bY#=Object position Y(2)
bZ#=Object position Z(2)

if BulletLife = 0
Hide object 2

endif

Endif


for bulletloop = 666 to 700

cbmX# = object position X(bulletloop)

cbmY# = object position Y(bulletloop)

cbmZ# = object position Z(bulletloop)

if bX# = cbmX# and bY# = cmbY# and bZ# = cmbZ#

hide object bulletloop

endif



Rem Control input for camera

if escapekey() = 1
end
endif
If Upkey()=1

XTest# = Newxvalue(X#,CameraAngleY#,10)
ZTest# = Newzvalue(Z#,CameraAngleY#,10)
If XTest#>0 and XTest#0 and ZTest#0 and XTest#0 and ZTest#0 and XTest#0 and ZTest#0 and XTest#0 and ZTest#0 and XTest#0 and ZTest#
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 11th Dec 2002 03:58
Looks like you are just missing a

Next bulletloop

at the end of your for bulletloop = 666 to 700 loop.

TDK
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 11th Dec 2002 04:03
There's no Endif at the very end or a Loop to match the Do either (looks like you put an Endif instead of a Loop).

These sorts of errors are easier to track down if you indent all your loops (Do/Loop If/Endif etc).

TDK
Dark_Programmer
21
Years of Service
User Offline
Joined: 10th Dec 2002
Location:
Posted: 12th Dec 2002 01:36
Stupid Me!!

But now i got that loop working and even if if shoot the ennemies, it doesnt do anything heeeeeeeeeeeelp me !!

Im posting the code below

Dark_Programmer
21
Years of Service
User Offline
Joined: 10th Dec 2002
Location:
Posted: 12th Dec 2002 01:38
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 bullet
Load image "C:\Program Files\Dark Basic Software\bullet.bmp",10
Make Object Sphere 2,0.45
Texture object 2,10
Hide object 2






Rem intialize particle counter
Pn=10



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

Rem texture matrix
Load image "C:\Program Files\Dark Basic Software\stoney02.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 make scorpions

for scorploop = 666 to 700
Load object "D:\Games\DarkBasic\Myproj\Room\obj\ScorpWalk.x",scorploop


scorpY# = int(rnd(10000))
scorpZ# = int(rnd(10000))
scorpX# = Get ground height(1,scorpX#,scorpZ#)

loop object scorploop
position object scorploop, scorpY#,scorpX#+270 ,scorpZ#
next scorploop

rem Make Gun
Load image "C:\Program Files\Dark Basic Software\metal.bmp",3

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
texture object 1,3
Lock object on 1


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








Rem Shoot


If mouseclick()=1
Load 3Dsound "C:\Program Files\Dark Basic Software\cannon.wav",12
play sound 12
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
bX#=Object position X(2)
bY#=Object position Y(2)
bZ#=Object position Z(2)

if BulletLife = 0
Hide object 2

endif

Endif

for bulletloop = 666 to 700

cbmX# = object position X(bulletloop)

cbmY# = object position Y(bulletloop)
cbmZ# = object position Z(bulletloop)

if bX# = cbmX# and bY# = cmbY# and bZ# = cmbZ#
hide object bulletloop

endif
next bulletloop



Rem Control input for camera

if escapekey() = 1
end
endif
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 Upkey()=1 and Shiftkey() = 1

XTest# = Newxvalue(X#,CameraAngleY#,13)
ZTest# = Newzvalue(Z#,CameraAngleY#,13)
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#<50000 and ZTest#>0 and ZTest#<50000
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#

Rem Refresh Screen
Sync
Loop

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 12th Dec 2002 03:42
It's difficult to figure out exactly what the problem is when you can't run the code. Maybe you could attach the media files in a zip, or alternatives if you prefer.

Your code was very hard to read as it was, so I've reposted it after tidying it up a little. You may find someone can help with your problem without having to run it when it's laid out properly.

Finally, in the beginning of your 'shoot' block, you load the sound file every time you click the mouse. You only need to load it once at the start of the program then use Play Sound - just like you would load an object just once.



TDK

Login to post a reply

Server time is: 2024-11-23 17:42:51
Your offset time is: 2024-11-23 17:42:51