Computer Science Canada Quickest way to get to a number |
Author: | Atherial [ Thu Jan 07, 2016 10:18 pm ] | ||
Post subject: | Quickest way to get to a number | ||
Basically, my summative due date is coming up and im panicking. My game has a sprite that spins a full 360 degrees. I need my sprite to turn based on my WASD key presses I could do the actual rotation of the sprite, however I need to figure out what the fastest way to get from one number to another is. So basically, if I pressed D id want the angle of my sprite to become 0. So if the angle was 45, id want it to slowly subtract slowly until it reached 0, if it was -45, id want it to add until it reached 0. This is my code so far, but I cant seem to think it out in my head (angle 0 is my sprite facing right, 90 is up, 180 is left, -90 is down. My array is from -180 to 180 for each angle.)
Does anyone have any pre made procedures to do this? Or any reccomendations to make sure Im doing this correctly? Super urgent that I need a response. Thanks so much for the help! -Mackenzie |
Author: | Atherial [ Mon Jan 11, 2016 10:48 am ] |
Post subject: | Re: Quickest way to get to a number |
Solved with a ton of if statements. |