Jump to content
  • Advertisement
Sign in to follow this  
Luzhi

OpenGL bullet implementation

This topic is 4794 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im wrting my first game, and so far i have triangle, and i can move it around:) Now i want to make it fire bullets. I was thinking of making smal object, or to try with particles? To be honest i dont know what particles are, just saw somwhere that it can be used for simulating bullets:).

Share this post


Link to post
Share on other sites
Advertisement
Bullets travel at well over a thousand miles per hour. You are not going to see a bullet. What you will see is a muzzle flash. (Some games also fake a "bullet trail" with a glowing line.)

Share this post


Link to post
Share on other sites
As sneftel suggested, you probably just want something bullet-ish, but that moves at a perceptible rate (like in Asteroids). For this you'll need just a few things:

1. The position of your triangle
2. The angle of rotation of your triangle
3. A direction vector derived from the angle of rotation
4. The equation 'bullet.pos += direction * bullet.speed * frame_time'
5. Some way to render the bullet, such as GL_POINTS

At some point you'll have to deal with managing the lifetime and number of bullets. You might also want to start the bullet at the tip of the triangle rather than at the center.

'Hope that helps.

Share this post


Link to post
Share on other sites
To Sneftel: My bullets can be seen and they are not that fast, its my game :)

To jyk: Thanks, that is what i was looking for. I had 1-3, diddnt think about 4 yet since I didnt had 5 :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!