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 Professional Discussion / GuN isnt shooting?!

Author
Message
Deathr0w
21
Years of Service
User Offline
Joined: 22nd Dec 2002
Location:
Posted: 23rd Dec 2002 19:16
Ok i am making a game... its third person and ure a small tank that goes around shooting f*ck all
I am having a few problems with getting it to shoot...

Here is my script
-------------------------------------------------------
Sync On
Sync Rate 30

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

Rem texture matrix
Load image "C:\Documents and Settings\Administrator\Desktop\Modernage\textures\grass.bmp",1
Prepare matrix texture 1,1,1,1
Fill matrix 1,0,1

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
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 Main loop
Do
set cursor 0,0
print X#
print Y#
print Z#

Rem Store Object angle
CameraAngleY# = Camera angle Y()

Rem Control input for camera
If Upkey()=1
XTest# = Newxvalue(X#,CameraAngleY#,20)
ZTest# = Newzvalue(Z#,CameraAngleY#,20)
If XTest#>0 and XTest#0 and ZTest#
Deathr0w
21
Years of Service
User Offline
Joined: 22nd Dec 2002
Location:
Posted: 23rd Dec 2002 19:18
DELETED!!!

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Dec 2002 19:21
Incomplete post. Give us that last bit and we may be able to look at it for you
Deathr0w
21
Years of Service
User Offline
Joined: 22nd Dec 2002
Location:
Posted: 23rd Dec 2002 19:55
Sync On
Sync Rate 30

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

Rem texture matrix
Load image "C:\Documents and Settings\Administrator\Desktop\Modernage\textures\grass.bmp",1
Prepare matrix texture 1,1,1,1
Fill matrix 1,0,1

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
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 Main loop
Do
set cursor 0,0
print X#
print Y#
print Z#

Rem Store Object angle
CameraAngleY# = Camera angle Y()

Rem Control input for camera
If Upkey()=1
XTest# = Newxvalue(X#,CameraAngleY#,20)
ZTest# = Newzvalue(Z#,CameraAngleY#,20)
If XTest#>0 and XTest#<10000 and ZTest#>0 and ZTest#<10000
Move camera 10
Endif
Endif

If Leftkey()=1 then Yrotate Camera Wrapvalue(CameraAngleY#-5)
If Rightkey()=1 then Yrotate Camera Wrapvalue(CameraAngleY#+5)
X# = Camera position X()
Z# = Camera position Z()
Y# = Get ground height(1,X#,Z#)
Position Camera X#,Y#+35,Z#

Rem Refresh Screen
Sync

Loop

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Dec 2002 20:01
Should have seen it already. The bullet routine is not inside your main loop.

Take the code from 'if Mouseclick()=1 and BulletLife=0
' up to the following blank line, and move it to just before the sync. That should do it.
Deathr0w
21
Years of Service
User Offline
Joined: 22nd Dec 2002
Location:
Posted: 23rd Dec 2002 20:57
Awww thanx man all sorted now.... can u tell me how I would put in keys for example:

If Upkey()=1
XTest# = Newxvalue(X#,AngleY#,100)
ZTest# = Newzvalue(Z#,AngleY#,100)
If XTest#>0 and XTest#<10000 and ZTest#>0 and ZTest#<10000
Move object 10,10
Endif
Endif

What if i wanted it to be 'N' that i pressed instead of the 'Upkey' what would i type in?

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Dec 2002 21:06
Use this to get the scancode for your keys



I've included a keystate check for the N key so that you can see how to do it. To get a scancode for the escape key you will have to use 'disable escapekey', but don't forget to leave yourself another way out of your program.
Deathr0w
21
Years of Service
User Offline
Joined: 22nd Dec 2002
Location:
Posted: 23rd Dec 2002 21:10
Oh man my head hurts with all this information

Deathr0w
21
Years of Service
User Offline
Joined: 22nd Dec 2002
Location:
Posted: 23rd Dec 2002 21:11
Thanx alot man... tried the N button thing and w00t

Attreid
21
Years of Service
User Offline
Joined: 27th Nov 2002
Location:
Posted: 24th Dec 2002 13:19
Deathr0w, the programm read the lines one after the other. if you want it to read the ame lines, you have to use "do .. loop".
when it read "loop", it come back to "do". so when you have an action out of the loop, for example :
"
make object cube 1,1
if spacekey()=1 then turn object left 1,5
do
loop
"
it will turn the object only one time, if you press the spacekey when the programm is reading the second line ( during only a few milliseconds ).
but if you put the second line in the loop, it will read this line until you close your programme => you can press the spacekey when you want

I'm following John, but I'm not john.
Lol, it is funnier in french
Deathr0w
21
Years of Service
User Offline
Joined: 22nd Dec 2002
Location:
Posted: 24th Dec 2002 18:57
Oh now i understand

Thanx

Login to post a reply

Server time is: 2024-05-04 22:24:53
Your offset time is: 2024-05-04 22:24:53