Computer Science Canada Move Object At An Angle |
Author: | Jeffmagma [ Tue Dec 22, 2015 11:32 am ] | ||
Post subject: | Move Object At An Angle | ||
What is it you are trying to achieve? I'm trying to move an object (or just a pixel) at an angle. If i divide it small enough to move 1 pixel at a time, it only goes in 1 direction, but for example if the line is 1 pixel to the right then 2 pixels up then 1 to the right and so on, I want the movement to follow that pattern What is the problem you are having? I'm not exactly sure how to calculate how much it moves Describe what you have tried to solve this problem I've tried to make it move 1 pixel at a time towards an angle, but it would only go in 1 direction (used to be in moveF) Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Please specify what version of Turing you are using OpenTuring 1.0.1 |
Author: | Insectoid [ Tue Dec 22, 2015 2:12 pm ] |
Post subject: | RE:Move Object At An Angle |
First of all, you can ditch your radians function by switching from sin/cos to sind/cosd. sind is sine, in degrees. I don't have time right now to take a close look at your code, but I suspect that the issue has to do with when you round your variables off. You generally want to round at the last possible moment. All of your relevant variables should be of type real, even your x and y variables. |
Author: | Jeffmagma [ Tue Dec 22, 2015 2:33 pm ] |
Post subject: | Re: Move Object At An Angle |
Insectoid wrote: First of all, you can ditch your radians function by switching from sin/cos to sind/cosd. sind is sine, in degrees.
Thanks for telling me about sind/cosd! I didn't know about those! I'll try rounding a bit later and see if that works... EDIT: Rounding at the last moment worked! Thanks for your advice! |