Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Trajectory of Bullet
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
platky




PostPosted: 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...


Game.rar
 Description:
Tank Man

Download
 Filename:  Game.rar
 Filesize:  181.82 KB
 Downloaded:  56 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Dusk Eagle




PostPosted: 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 Smile.
platky




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




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: