Computer Science Canada movement |
Author: | metachief [ Sun Mar 30, 2008 1:53 pm ] |
Post subject: | movement |
hey guys. Could someone tell me how to make an object for example a box, move in a circle.. thx in advance |
Author: | Mackie [ Sun Mar 30, 2008 1:57 pm ] |
Post subject: | RE:movement |
http://compsci.ca/v3/viewtopic.php?t=114 Check that link out. I don't know if you want key movement or not. Either way you will be able to get what you need from that Tutorial. |
Author: | metachief [ Sun Mar 30, 2008 2:09 pm ] |
Post subject: | RE:movement |
actually that tutorial is only on key movement i dont need that..I was wondering how i can make by box move in a constant circle on its onwn |
Author: | BigBear [ Sun Mar 30, 2008 2:16 pm ] |
Post subject: | Re: movement |
have a loop where you draw the box then change where you draw the box then reapeat in the same circle. |
Author: | CodeMonkey2000 [ Sun Mar 30, 2008 2:38 pm ] |
Post subject: | RE:movement |
There are a bunch of ways you can do this. If you know the equation of the circle ((x-k)^2+(y-h)^2=r^2) you can take an x coordinate and figure out the corresponding y coordinate. |
Author: | metachief [ Sun Mar 30, 2008 2:56 pm ] |
Post subject: | RE:movement |
im still confused on how i would plucg that in...I know the formulas in math, but i don't knoiw how to apply them in turing (or at least for the circle) |
Author: | richcash [ Sun Mar 30, 2008 3:44 pm ] |
Post subject: | Re: movement |
Because the equation of a circle is not a function, it would be easier to use trigonometry to find the points of a circle at certain angles (I will give you the parametric equations, but it is easy to develop them with trigonometry). Given an angle, you can find the point on a circle at that angle with the parametric equations : x = cos(angle) * radius + center.x y = sin(angle) * radius + center.y To move one cycle of the circle, make angle go from 0 to 359. |
Author: | The_Bean [ Sun Mar 30, 2008 3:47 pm ] | ||
Post subject: | Re: movement | ||
OK 1 don't use the equation of a circle. I tried it and its really buggy and you need 4 of them to make a jerky circle. What you need is 2 variables a for statement and grade 11 math you have to use sind and cosd and putting in all angles between 0 and 360. using the formulas: x:=round(cosd(angle)*radius)+center of circle x y:=round(sind(angle)*radius)+center of circle y use the for statement for the angle for angle :0..360 x:=round(cosd(angle)*radius) y:=round(sind(angle)*radius) end for
|