• Advertisement
Sign in to follow this  

Drawing and calculating bullets in FPS

This topic is 4062 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

Hi everyone, I'm making a simple FPS game and I need little help :) I have a weapon which doesn't fire. I need to create bullets but I don't know how. Are there any tips, articles or tutorials about creating and firing sprites out of the weapon and rendering them? All I need is when pressing fire button a single shot to come from the weapon toward the center of the crosshair, and when it reaches a wall or smth. like that to split in 4-5 parts and disappear. Hope you understand me. Thanks in advance.

Share this post

Link to post
Share on other sites
I don't think that this is an OpenGL Problem,
but to answer your question:

I think drawing a single Bullet is not needed, 'cause its much to fast to be seen by the eye.
You should just compute the path of your bullet (as a ray), compute where it hits anything and start a little particle effect at the hitpoint.
If you want to draw the path of the bullet you could draw it as a line (like a glowing bullet-trace).

Share this post

Link to post
Share on other sites
Use a particle system.
Try my game at:
my game
and download the first game.
You can see sparks when you press fire.
I do about 200 particles for each fire bullet.
Also you can see bullets flying off (a bit too slowly though).
I do the bullets as very small cylinders (using quadrics).
eg suppose I'm facing in the normalised direction (vx, vy, vz) then I create a bullet with vector velocity:

Then each frame calc deltaTime since last frame so we can get new position

bulletpos += bulletpos + velocity*deltaTime

Then draw the bullet.

glTranslatef(bulletpos.x, bulletpos.y, bulletpos.z)
drawBullet using quadrics

(try different values of magnitude - hint - bullets go at 500m/s but you won't be able to see them at that speed)

For the particle system for an intro go to:
nehe particle sys
second example from the end
Also the book on "Focus on 3D Terrain Programming" has a good example as does the book "Game Programming with OpenGL"

I deserve to be rated up a lot for this ! hint hint

Share this post

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

  • Advertisement