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 / How do you make bullets?

Author
Message
Bloder
18
Years of Service
User Offline
Joined: 24th Feb 2007
Location: Cyberspace
Posted: 11th Feb 2008 19:47 Edited at: 11th Feb 2008 20:02
Excuse me, does anyone have a code where you can create a sphere bullet that appears in front of the player when you press space bar? I'm only **!

[Mod Edit] It is against the AUP to state your age. TDK
Insert Name Here
18
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 11th Feb 2008 20:10



This image is purely work in progress.
BMacZero
19
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 11th Feb 2008 20:30
I can do better
Oh, and you forgot to sync, INH



Read some tutorials. They're stickied at the top of this board.


Powered by Box2D Physics. Thanks Diggsey!
Insert Name Here
18
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 11th Feb 2008 20:44
Quote: "I can do better
Oh, and you forgot to sync, INH"


Yeah, I know. That snippet was kinda sarcastic, you realize.


This image is purely work in progress.
DB newbie
19
Years of Service
User Offline
Joined: 13th Nov 2005
Location: um..... i dont remember.
Posted: 11th Feb 2008 20:50
simply put, you make a sphere hide it then when your fire button is pressed show teh object and move it


Come see the WIP!

BMacZero
19
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 11th Feb 2008 20:52
Oh, I get it


Powered by Box2D Physics. Thanks Diggsey!
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 11th Feb 2008 22:06
But it's not very realistic.

If you think about it, when a gun fires, do you see the bullet?

If you aren't bothered with realism, using an object is fine until you want it to move very fast.

Doing this requires you to increase the distance it moves per loop cycle and invariably causes problems with collision (if you are using it to detect a hit).

This is because moving the bullet far enough to give the appearance of high speed, it can often jump to the other side of the target - making it appear to pass 'through' the target and registering a miss.

It's far easier to decide on a 'hit' when targeting and just play the gun sound when you fire. As a bullet moves so fast, provided the gun site is on the target when the fire button is pressed, you assume a hit.

That's why many games add a bit of drift when aiming to make a guaranteed hit a little more difficult.

TDK_Man

Not_Maindric
17
Years of Service
User Offline
Joined: 10th Jul 2007
Location: Omaha, NE
Posted: 12th Feb 2008 02:58
What I would do for a bullet is something like this. I am very sure there are better ways to do this, but this was mainly an expearament on my part.



Of course, it is slow right now, but the reason being, if it is fast, you would not be able to see it, I tried, but I would do something like this mainly for a sniper. Becouse, in real life, after a distance, gravity pulls the bullet down, so if you speed up the X movement, it will be more realistic, and will cuase the realistic delay time with the hit time, depending on distance, but at the same time, if applied right, you will only see a blur of the object. This is just my veiws, any opinions? Also, this is only for a 2D Plane going left to right, and it is very boring. =P I still suck at DBC. Please tell me if I can do something to make it better.

@Bloder
This is just what I would do, for a 3D envoronment, it would be harder, but I hope this broadened your thoughts...

SimSmall
20
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 12th Feb 2008 11:48
Quote: "This is because moving the bullet far enough to give the appearance of high speed, it can often jump to the other side of the target"


Not necessarily, back in the days I'd use this system (before migrating to DBP and Newton physics) To move 1000 units for example I would instead tell it to move 1 unit, 1000 times (checking for collision before the bullet move again). With the bullet being a plain, that was 1 unit long it couldn't fly through anything in the way, and you'd need about 300 of these bullets before the frame rate dropped below about 30.

Of course, raycasting is much faster. If you can make a physics engine like Newton or Tokamak work with DBC, you'll notice it's significantly faster...
KISTech
17
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 12th Feb 2008 17:52
I was about to suggest, cast a ray from the gun barrel to the bullet after each move. Then you can move the bullet as fast or as far as is needed and when the ray impacts something other than the bullet you register a hit on that object, and delete the bullet.


Don't think, just code.
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 12th Feb 2008 19:14
How do you do ray casting?

Insert Name Here
18
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 12th Feb 2008 19:53
You just took the words right out of my mouth, Obese.


This image is purely work in progress.
Link102
20
Years of Service
User Offline
Joined: 1st Dec 2004
Location: On your head, weeeeee!
Posted: 12th Feb 2008 20:12 Edited at: 12th Feb 2008 20:13

Attachments

Login to view attachments
KISTech
17
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 12th Feb 2008 20:17
There are commands for ray casting in DarkPhysX.


Don't think, just code.
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 12th Feb 2008 23:18
Quote: "There are commands for ray casting in DarkPhysX"


Which DBC users can't use...

TDK_Man

KISTech
17
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 12th Feb 2008 23:24
Doh!!


Don't think, just code.
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 14th Feb 2008 17:36
How about this:

rem setup screen
sync on
sync rate 30
backdrop on
color backdrop 0
hide mouse

rem make 10 bullet objects
for t=1 to 10

Oooooops!!! I accidentally formated drive c.
Insert Name Here
18
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 14th Feb 2008 17:55
for t=1 to 10... what?

You can write crap in DBPro as well as DBC - it just crashes quicker! -TDK

TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 14th Feb 2008 17:55 Edited at: 14th Feb 2008 17:57
@ Insert Name Here
I posted the post when it wasn`t finished by accident...

How about this:



Oooooops!!! I accidentally formated drive c.
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 15th Feb 2008 04:30
Or you can check out a tutorial on the subject:

http://forum.thegamecreators.com/?m=forum_view&t=99497&b=10

(Tutorial 11).

It's for 2D, but when you get how it works, doing the same in 3D is easy.

TDK_Man

jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 21st Feb 2008 17:58
You can do a ray cast... kinda like was mentioned...sorta... a fudge.... but should work I think......


Make a Super long "ROD" object.... position length/2 behind gun origin - oriented to camera or gun... this thing should be as long as bullet range.... then use native intersect object commands... slide it ot whatever...

Not Exactly RayCasting - but a workable fudge.

Login to post a reply

Server time is: 2025-06-04 02:17:16
Your offset time is: 2025-06-04 02:17:16