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 / Automatic Gun Sounds Problem

Author
Message
Malith
20
Years of Service
User Offline
Joined: 12th Mar 2005
Location: nowhere
Posted: 31st May 2005 20:32
I have an automatic gun in my FPS I am making with some buddies in DarkBASIC. My code ends up, the closer the bullet is to the object it collides with, the faster the automatic weapon's sound plays, as the farther away the bullet is (I.E. shooting the sky), it plays one shot, and waits until the bullet gets a certain distance before hiding itself and being able to shoot again. any ideas?
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 31st May 2005 23:05
My guess is, you only have one bullet, and your gun only shoots when the bullet is available.

You need an array of bullets, so that you always have a bullet available, even if there are others in mid-flight. If you do this, you might also need to consider forcing a delay between shots, otherwise you'll end up shooting 100 bullets in a split second.

BatVink
Malith
20
Years of Service
User Offline
Joined: 12th Mar 2005
Location: nowhere
Posted: 31st May 2005 23:45
How would I go about doing this though?
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 1st Jun 2005 04:04
Malith,

I noticed that you double posted on this topic. I would say to stray away from doing such. Below is a copy of what I posted in your other post....

You need to create more than just one bullet object as your projectile. Instead, create enough bullets that you will not cycle through them all before the last bullet shot runs out of 'life'. Let's say that each bullet's life will last to 300 units out, and their speed will be 5 units each frame(game loop). Let's also say that you wish to shoot a bullet every 5 frames, as long as the 'trigger' is held down. Let's do some math.

Simply, divide the bullets' lifes by the distance they will travel each frame. 300 / 5 = 60. So, we need 60 bullets to make this loop fluent.

Now, there is a need for an array to control all the properties of each bullets. What do we need to record? In the 2D program I need to record the bullets' x and y coordinates. In 3D, you may need to record their z coordinates. Also, their bulletlife, in which this value will also be used to make the bullet move if it is above 0 bulletlife. Lastly, bulletangle.

The code snippet below is a small program made in order to show this loop working. It is all in 2D, however, we're not focusing on the graphics, but the loop. The code is heavily commented to guide you through it processes. Enjoy!




+NanoBrain+
Malith
20
Years of Service
User Offline
Joined: 12th Mar 2005
Location: nowhere
Posted: 1st Jun 2005 07:28
Sorry about the repost, I was having browser problems at the time. Nanobrain thank you so much for the little snippet, im looking at it right now, and trying to learn this, so I can program it myself next time!
Malith
20
Years of Service
User Offline
Joined: 12th Mar 2005
Location: nowhere
Posted: 1st Jun 2005 07:36
<img src="http://malith.game-server.cc:51/darkbasic_problem.jpg">

Login to post a reply

Server time is: 2025-05-23 02:03:40
Your offset time is: 2025-05-23 02:03:40