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 / how does any one make a simple gun shot

Author
Message
mr_fan
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: look... behind you.
Posted: 15th Apr 2005 13:58
I am fairly new at programing, i have finished the dark basic book and now i just need to know if anyone hase a simple code snipit for a gun bullet. i already have the guns and guy who walks around with a mind of his own i just need to know how to make a gun bullet, and some help with object colision.
Dark Flame
19
Years of Service
User Offline
Joined: 15th Feb 2005
Location: England
Posted: 15th Apr 2005 21:45
You could just use a sphere as a bullet...

mr_fan
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: look... behind you.
Posted: 16th Apr 2005 03:21
I tried to do that but it would only move when i hit the spacekey,
also i dont know how to respawn the bullet so that you can fire more then once.
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 16th Apr 2005 06:28
Here's some code I wrote as a basic FPS target practice type game.
The bullet function can be taken out and used. I also had a flame thrower option, which you can remove. Main thing is, take a look at the functions, see how I handled the coding, get some ideas, and go for it.



"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
mr_fan
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: look... behind you.
Posted: 17th Apr 2005 06:36
wow! that is a big code. i am having truoble understanding it though, does the bullet function need any other things to get it going? heres a source code if this will help out.
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 17th Apr 2005 07:26
here is how i have solved the problem
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 19th Apr 2005 09:54
Here's the main bullet handling code:


It's a pretty basic concept.

1) Decide on a range of object to be your bullets.
2) As the gun is fired, create the next object in sequence in the range. When you get to the end of the range, start over - the 1st bullet probably is pretty far away (out of sight) or hit something by then anyway.
3) Use for/next loop to check all the possible bullets in the range. If the object exists - simply move it forward.
4) As you are moving the object forward, check for collisions along the way. Handle appropriately.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
mr_fan
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: look... behind you.
Posted: 29th Apr 2005 12:49
WoW I need to wait to download it from my moms computer to mine (internet signal=poop ). I can't wait to try it! thanks evryone!

Login to post a reply

Server time is: 2024-09-23 19:32:13
Your offset time is: 2024-09-23 19:32:13