Jump to content
  • Advertisement
Sign in to follow this  
Olentzero

Programing technique: Shooting

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

Buenos días amigos, The current project of my course "Graficos por computador" (C++ & OpenGL) is to build a space scenery where one can handle a space cruiser. The navigation of the cruiser is almost finished and now i like to implement the shooting guns. That for i got a question in the beginning: How do you organise the shots and how to you proces with everyone of them? I wondered if its a good idea to save every shot with its position, direction, speed and color in a C++-struct. Then to save all shot-struct-objects in an array (better would be a dynamic solution but i dont know how to do that in c++) and to walk this array through at every frame. For every shot i add the direction to the position and get therefore the new position. Is that a comon procedure or am i completely wrong;) Muchas gracias para vuestras ganas de ayudarme

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Olentzero
How do you organise the shots and how to you proces with everyone of them? I wondered if its a good idea to save every shot with its position, direction, speed and color in a C++-struct. Then to save all shot-struct-objects in an array (better would be a dynamic solution but i dont know how to do that in c++) and to walk this array through at every frame. For every shot i add the direction to the position and get therefore the new position. Is that a comon procedure or am i completely wrong;)
For a simple demo, that sounds fine (you'll probably want to scale the direction vector by speed, and also timestep so that the motion is framerate-independent).

There are various other things you could do, such as making your projectiles a class (by convention) that manages both the state and behavior of the projectile, or using a standard library container such as vector or list to manage the projectiles dynamically. Again though, for a homework-related demo I think the simplest possible solution would probably suffice.

(Mods: I'm assuming the homework-related advice in this post is acceptable, as I've provided some ideas and terms to look into but no code or details of implementation.)

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!