Home | Rules and Guide | Sign In/Create Account | Write a Post | Reddit | | #ludumdare on irc.afternet.org (Info)

Ludum Dare 29 — April 25th-28th Weekend [9 PM EST] — Theme: ??? (Theme Voting!)
  • Ludum Dare 29 Compo (48 Hour+Solo+Scratch+Src) Begins: in 6 days, 5 hours, 8 minutes, 12 seconds
  • Ludum Dare 29 Jam (72 Hour+Teams OK+Relaxed) Begins: in 6 days, 5 hours, 8 minutes, 13 seconds
  • [ MiniLD 50 | Warmup Weekend April 19th-20th | Real World Gatherings | Ludum Deals | Wallpaper ]


    Looking good, but i have a problem!

    Posted by (twitter: @petterroea)
    December 17th, 2011 8:14 am

    Yup. I need the player, at a constant coordinate of 400, 300, to face the mouse. And i suck at stuff like this? Any help?

    rotation degrees = 0 when facing right. Up is 270. ect…

    2 Responses to “Looking good, but i have a problem!”

    1. delpes says:

      float radiansToMouse = (float) Math.atan2(400 – input.getMouseX(), 300 – input.getMouseY());
      float degreesToMouse = (57.2957795f * radiansToMouse) * -1;
      heroImage.setRotation(degreesToMouse);

      Something like this?

    2. petterroea says:

      Yes, thanks! You saved my day!

    Leave a Reply

    You must be logged in to post a comment.


    All posts, images, and comments are owned by their creators.

    [cache: storing page]