Posted: Mon Mar 30, 2009 6:42 pm Post subject: Trajectory of Bullet
Im having a new problem with my trajectory of my bullets. I have only done some incredibly simple attempts at getting the trajectory right but its just not accurate as you will clealry see if you try my game. I know there is a way or some equation/method to do this i just cant think of anything that would properly work. If you have any suggestions please help...
Posted: Tue Mar 31, 2009 12:20 am Post subject: Re: Trajectory of Bullet
The horizontal distance the bullet has traveled:
code:
d = vt
where d = distance; v = speed of bullet; t = time since bullet launched.
The vertical distance the bullet has traveled:
code:
d= vt + 0.5at^2
where a = acceleration due to gravity = -9.8 on Earth.
BTW, you're using far too many global variables in your program. Have you read up on parameters in http://compsci.ca/v3/viewtopic.php?t=14665? Doing so would really help you write cleaner, easier to maintain code .
platky
Posted: Tue Mar 31, 2009 9:12 am Post subject: RE:Trajectory of Bullet
thanks i got it to work well enough and the reason for the mess of variables is because everything is really makeshift and i just keep adding. I dont feel like cleaning it up yet...
Dusk Eagle
Posted: Tue Mar 31, 2009 1:59 pm Post subject: Re: Trajectory of Bullet
BTW, the v in the first formula should be the horizontal speed, and the v in the second formula should be the vertical speed. Just thought I'd clear that up for anyone reading.