Results 1 to 6 of 6

Thread: [Resolved]Getting angle of movement in radians via mouse

  1. #1

    Thread Starter
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913

    Resolved [Resolved]Getting angle of movement in radians via mouse

    Hey guys. I am really trying to wrap my head around this. What I am trying to get done is when the mouse is moved, I need to calculate the degree in radians it moved based on the local coordinate space of a sprite the mouse is moving. Basically I need to fire a bullet in that direction when I hit the fire button. I know how to animate it and all that, but just can't figure out how to get the radians based on mouse movement.

    Hope I explained that well enough. Think Geometry Wars as far as how I need to be firing the bullets. Any tips?

    I will eventually be using a 360 controller using the left stick for this, but for the time being I need to do this with a mouse for testing stuff at work where I don't dare bring in a game controller.
    Last edited by Cander; Dec 12th, 2006 at 12:13 PM.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  2. #2
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: [Any language]Getting angle of movement in radians via mouse

    I'd use the mousemovement event to get the X and Y value, compared against the last X and Y values (which you need to store in a global var), you can calculate the DeltaX and DeltaY.
    Where is your problem, how the get those DeltaX and DeltaY or how to calculate the radians from DeltaX and DeltaY?
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  3. #3

    Thread Starter
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913

    Re: [Any language]Getting angle of movement in radians via mouse

    Getting the DeltaX and Y is my issue. I know how to get the radians.

    My math is so rusty. Boo to getting old.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  4. #4

    Thread Starter
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913

    Re: [Any language]Getting angle of movement in radians via mouse

    Hey man thanks. Just by what you said after thinking about it I figured it out. Rep coming your way.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  5. #5
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: [Resolved]Getting angle of movement in radians via mouse

    Thanks!
    It's not only your math, that's getting rusty. I hope the math teached in the 20th century is still valid in the 21th
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  6. #6

    Thread Starter
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913

    Re: [Resolved]Getting angle of movement in radians via mouse

    Oh snap. I am burned.

    Thanks again.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width