Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
EvilCowSan
16
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United States
Posted: 7th Oct 2002 00:23
I'm doing a 2d game w/ mouse aim (ie the bullets are shot at where your mouse currently is) I figured out how to get all the appropriate angles and i have bullets that hit their mark, but the only problem is that i need a way to uniformly accelerate them (make them all go the same speed)
Right now i just get the tangent of my angle and increment x by that # and then increment the y by 1 or -1 respective to the quadrant. This works, but at different angles, the bullet goes really fast and some angles go really slow due to the tangent.
Any ideas? Thanx! =)
"Trumpy!"
The Darthster
16
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 7th Oct 2002 00:42
Get the sine and cosine of your angle and split the bullet vector up. Depending on where the zero angle is, your x velocity should be sin(theta)*velocity and your y velocity should be cos(theta)*velocity where theta is the angle of fire and velocity is the velocity you want all the bullets to fire at. The above equations are for when zero is on the vertical, if the zero angle is on the horizontal then just swap around the sin and cos functions. Did you understand that?
EvilCowSan
16
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United States
Posted: 7th Oct 2002 01:29
kewl thanx! I thought it might have something to do with the cos and sin when i was righting this, but i had no idea how they would fit in. =)

"Trumpy!"
Rodro
16
Years of Service
User Offline
Joined: 17th Sep 2002
Location:
Posted: 7th Oct 2002 03:20
Please show me the code for this discussion. It has been a long time since I've had trig.

Thanks.

Hey!! You talking to me?
EvilCowSan
16
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United States
Posted: 7th Oct 2002 03:42


Here's how i got the angle if that's what you mean.

"Trumpy!"
EvilCowSan
16
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United States
Posted: 7th Oct 2002 03:44
oh btw, most of the variables i used are floats so you'll have to declare the variables for the code to work.

"Trumpy!"
Rodro
16
Years of Service
User Offline
Joined: 17th Sep 2002
Location:
Posted: 7th Oct 2002 05:53
Thanks. Now what do I do with the results to move an object?

Sorry I'm so stupid in math.

Hey!! You talking to me?
EvilCowSan
16
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United States
Posted: 7th Oct 2002 06:35
This is for 2d first of all. And that code was just for finding the angle created between a point (gunx,guny) and the mouse

"Trumpy!"

Login to post a reply

Server time is: 2019-08-21 04:09:41
Your offset time is: 2019-08-21 04:09:41