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.

Dark GDK / Simple Shooting Method

Author
Message
Ninja_Je5us
14
Years of Service
User Offline
Joined: 1st Feb 2010
Location:
Posted: 23rd Nov 2010 20:08
On to the next feature of my game.

I am looking to get my plane to shoot bullets. My bullets will be a simple sphere to begin with. I want the bullets to come simultaneously from each wing.

Ive tried creating a bullet that comes from the front on the press of the return key that then travels forward using a while loop. This did not work and just created the bullet at the end of where the loop would have created it, the camera then focusing on it.

How can I go about doing this?
MPQC
14
Years of Service
User Offline
Joined: 7th Sep 2009
Location:
Posted: 23rd Nov 2010 22:17
Could we have a glimpse at what your code looks like for that?
Ninja_Je5us
14
Years of Service
User Offline
Joined: 1st Feb 2010
Location:
Posted: 23rd Nov 2010 22:44
Erm i got rid of it to be quite honest with you!

:/ sorry.
WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 23rd Nov 2010 23:21
Using the basics of a class you could set up your bullet handling code similar to this:


If you use this method then bullet handling is so much easier. A function could be used to search through say 10 gaps from ie 100-109 to see if a gap is available and use that one as the currently used bullet. The movement will handle the bullets lifespan and delete it when it has been finished with...

To init use bullet a(10)
To move it use a.move()

and that it...

Warning! May contain Nuts!
Ninja_Je5us
14
Years of Service
User Offline
Joined: 1st Feb 2010
Location:
Posted: 26th Nov 2010 09:16
Sorry how is it that you initialize the bullet class so that it's usable?

Im still trying to get a grasp on classes.

Regards
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 27th Nov 2010 17:09 Edited at: 27th Nov 2010 17:15
You really should read up on classes. They are one of the most useful objects in C++. Anyway, you don't have to use a class (though it's recommended). Try making two spheres and placing them at the wings. Make an array of integers about [200]. Each time you fire, "instance" the two spheres with two of the integers you just made, use "dbSetObjectToObjectOrientation(Obj1,Obj2)" to make them face the same direction as the plane, then each time you loop, check the [200] for "dbObjectExist(Obj)" and then "dbMoveObject(Obj,speed)". When it hits or gets too far away from the plane, "dbDeleteObject(Obj)". This is made much simpler with an class, with the same concept:

Make the bullets before the GDKLoop():

When you fire:

Each time you loop:


The fastest code is the code never written.

Login to post a reply

Server time is: 2024-06-30 10:41:57
Your offset time is: 2024-06-30 10:41:57