Sign in to follow this  
Olentzero

Programing technique: Shooting

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this