Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Xna

Options
  • 13-09-2013 11:18am
    #1
    Registered Users Posts: 3,500 ✭✭✭


    Hey I have a bit of a maths question that I need help with. Any help'd be great.

    Just messing around in Xna and messing with sprites and stuff/

    I have a square (a 48 * 48 image) which I can track on screen by the x and y of the top left point of the square. This is all fine. I want to be able to rotate the square and still keep track of the same point. for instance if I rotate 90degrees clockwise and the orginal X position was 200 the new X position should be 200 + 48(the size of the width of the image). Its fine for 90 degrees I am able to work that out in my head but each one in between is the problem! I know there is prob some kind of formula to work this out. Any help would be great! Oh the square is rotating on its center


Comments

  • Registered Users Posts: 12,754 ✭✭✭✭Encrypted Pigeon


    If the square is rotating about the center as it is, why not do your calculations based on the center of the sprite?

    Anyway this (http://gamedev.stackexchange.com/a/18341 is one way of doing it, you know the radius and center of the sprite and angle you are rotating about the origin so simple trigonometry.

    Edit: fix link


  • Registered Users Posts: 3,500 ✭✭✭Drexel


    CoderDozer wrote: »
    If the square is rotating about the center as it is, why not do your calculations based on the center of the sprite?

    Anyway this (http://gamedev.stackexchange.com/a/18341 is one way of doing it, you know the radius and center of the sprite and angle you are rotating about the origin so simple trigonometry.

    Edit: fix link

    Nice one. Thats exactly what I was looking for. I knew there was some way to work it out but wasnt sure what to google! Now to remember it all!!


Advertisement