# Projecting Projectile Path

5 posts

 1 post Hey guys, I’m working on a game for my programming class and I came across a topic that I honestly don’t know how to approach. You all know the game Gravitee by FunkyPear right? well my game is in a solar system with planets much like the ones in Gravitee, and you fly around in a ship, defending your planet from alien invaders. I wanted to add a trajectory line for your ship, and the bullets that are being fired, but I don’t know how to draw this line on the screen/calculate it. Any help is greatly appreciated. - Cevil 521 posts If you have the ability to move your ship according to the conditions (gravity, velocity…) then just simulated a second ship (or number of them) which are ahead of your ship, showing where it will go. 6860 posts You aren’t projecting projectiles,1 your predicting them. 1 (Actually, you are, but that word is not the word you are looking for.) 562 posts If you have more than one gravity well, predicting the projectile path with pure math equations is going to be really quite challenging. I would use an iterative approach. Run a quick simulation to work out where your bullet will go, using the same calculations you use in your game loop. Add all the points to an array, and draw a line through them. 113 posts Originally posted by CuriousGaming:Add all the points to an array, and draw a line through them. It would be better to draw the line while you are simulating the projectile. Also, if this applies to your game, only simulate the path when you changed the aiming angle to avoid unneccesary performance loss.