by Phyll » Sat Jan 21, 2012 2:13 pm
Hi MakyOnCover,
That's kind of a nebulous question and I haven't actually written any code for "tracer fire" as it seems you would like to create. But if I were to do that...
I would probably create a Tracer object. It would contain a bitmap, its current x,y location, its m and b from the equation for its tajectory (simple straight line). At least. And maybe a counter so that every tracer was not updated at exactly the same time. And maybe a max count so that individual tracer objects could have their own speed.
I would probably have a tracer object represented by a bitmap if the detail had to be great (tail or something). Otherwise I would draw a simple dot of some kind to represent it. A tail would mean also aligning the bitmap with the trajectory (something that could get pretty ugly).
A clock would drive the screen update and do it whenever the counter in my tracer object reached a preset count. That preset number would determine its speed.
During a screen update, the draw routine would go through an array of such tracer objects updating each one that was ready to be drawn by calculating its next position and putting the bitmap there (maybe in the proper orientation) and updating its counter and location information.
If you wanted a more realistic trajectory, you could use actual balistic data and calculate the trajectory based on time and speed for a particular projectile and take gravity and windage into account. That would produce some kind of arc but may actually take too long calculating and drawing for a high frame rate.
Hope this helps.
Phyll