Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

JJXtra

Getting destination with an angle

This topic is 5967 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ive been trying to figure out how to get destination points given a certain angle. I''ve been using sin and cos for amounts moved, but Im having a problem finding edge destinations. For example, I have a ship on the screen, and it is facing at any angle (0-360), how would I check where a line from the ship intersects the edge of the screen? My res. is 1024x768. My brain is fried, any help is appreciated. Thanks- Jeff

Share this post


Link to post
Share on other sites
Advertisement
Solve the equations :

left edge : x = 0
ship : x = x0 + t.cos(a), y = y0 + t.sin(a)

solve for t, that gives you the intersection with the left edge.

Lather, rinse, repeat.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!