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 / FPS Shooting Bullet Delay

Author
Message
AJ Schaeffer
16
Years of Service
User Offline
Joined: 22nd Aug 2009
Location: Jacksonville,FL
Posted: 4th Aug 2010 22:32
I need help adding a delay for when the gun fires.

Interplanetary Funk
16
Years of Service
User Offline
Joined: 19th Apr 2010
Location: Ipswich, United Kingdom
Posted: 4th Aug 2010 22:36
Your questions a bit vague, I'm not entirely sure what you're asking.
though for that snippet you posted try this instead:


(the colons represent a new line. dec decreases the value of the variable after it, you can also do this : "dec _VAR, _AMOUNT" where amount is the amount you want to decrease the variable by.)
AJ Schaeffer
16
Years of Service
User Offline
Joined: 22nd Aug 2009
Location: Jacksonville,FL
Posted: 4th Aug 2010 22:52
the snippet you posted works, but it waits 1 second before anything happens so if i hold down the mouse button it runs at 1 frame per second

Quote: "Your questions a bit vague, I'm not entirely sure what you're asking."


i need a delay so all 30 of the bullets dont shoot at once
Interplanetary Funk
16
Years of Service
User Offline
Joined: 19th Apr 2010
Location: Ipswich, United Kingdom
Posted: 4th Aug 2010 23:02
Ah, I get you. try this:



this gets the time difference between when it last shot and when you're trying to shoot. If enough time has elapsed it will then shoot another bullet and reset the _LAST_SHOT variable.
AJ Schaeffer
16
Years of Service
User Offline
Joined: 22nd Aug 2009
Location: Jacksonville,FL
Posted: 5th Aug 2010 00:33
where do i put that? if i put it in the main loop the variable doesnt change at all

thanks for the help and cooperation also
Interplanetary Funk
16
Years of Service
User Offline
Joined: 19th Apr 2010
Location: Ipswich, United Kingdom
Posted: 5th Aug 2010 00:37
put

outside the main loop, e.g. after you've set up the game window and any other variables. if you need to access them in several functions declare them like this:


and I didn't mention in the last post, that the bullet delay is in milliseconds.

and NP, I get help from these forums all the time, it's only fair to give some back =)
AJ Schaeffer
16
Years of Service
User Offline
Joined: 22nd Aug 2009
Location: Jacksonville,FL
Posted: 5th Aug 2010 00:54
um i still have the same problem. heres the code and the exe
its probably just me doing something wrong




god im a pain arent i?
Interplanetary Funk
16
Years of Service
User Offline
Joined: 19th Apr 2010
Location: Ipswich, United Kingdom
Posted: 5th Aug 2010 02:11
try this:


some functions you can only call once per loop and won't work if you call it multiple times.

and don't worry about being a pain =) I'm glad to help
AJ Schaeffer
16
Years of Service
User Offline
Joined: 22nd Aug 2009
Location: Jacksonville,FL
Posted: 5th Aug 2010 02:27
where does this go?
(when this is all done ill remember who to give a free copy to )
Interplanetary Funk
16
Years of Service
User Offline
Joined: 19th Apr 2010
Location: Ipswich, United Kingdom
Posted: 5th Aug 2010 02:51 Edited at: 5th Aug 2010 02:52


between the "/////" =)
AJ Schaeffer
16
Years of Service
User Offline
Joined: 22nd Aug 2009
Location: Jacksonville,FL
Posted: 5th Aug 2010 03:14
but it still does the same thing
Interplanetary Funk
16
Years of Service
User Offline
Joined: 19th Apr 2010
Location: Ipswich, United Kingdom
Posted: 5th Aug 2010 03:27 Edited at: 5th Aug 2010 03:28
Sorry, I forgot to remove the "wait 1000" command, completely remove that, it should work fine.
also, change it not to shoot when ammo is 0 because then you go into negative ammo, which wouldn't be good =)
AJ Schaeffer
16
Years of Service
User Offline
Joined: 22nd Aug 2009
Location: Jacksonville,FL
Posted: 5th Aug 2010 03:39
sweet thanks!
now only if it could dec faster...hmm...
Interplanetary Funk
16
Years of Service
User Offline
Joined: 19th Apr 2010
Location: Ipswich, United Kingdom
Posted: 5th Aug 2010 04:49

=)
AJ Schaeffer
16
Years of Service
User Offline
Joined: 22nd Aug 2009
Location: Jacksonville,FL
Posted: 5th Aug 2010 05:04
alrighty now it decreases by 3 since there are about 3 shots fired before it changes. yaaaaaaaaay now im going to start working on reloading and picking up ammo.oh dang i still have to do collision...waaaaaaaaaaaaaaaaaaaaaaaaaah
AJ Schaeffer
16
Years of Service
User Offline
Joined: 22nd Aug 2009
Location: Jacksonville,FL
Posted: 5th Aug 2010 05:10
wait...that doesnt work for single shooting...DANG'T I CANT WIN! how can i decrease the delay time?
Interplanetary Funk
16
Years of Service
User Offline
Joined: 19th Apr 2010
Location: Ipswich, United Kingdom
Posted: 5th Aug 2010 15:13
change the _BULLET_DELAY variable to the value you want, remember its in milliseconds.
AJ Schaeffer
16
Years of Service
User Offline
Joined: 22nd Aug 2009
Location: Jacksonville,FL
Posted: 5th Aug 2010 19:42
holy mackeral it works yesssssssss!!! thank you so much! have a beer and a carrot !

Login to post a reply

Server time is: 2026-07-25 02:47:08
Your offset time is: 2026-07-25 02:47:08