movement
Author |
Message |
metachief
|
Posted: 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 |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Mackie
|
Posted: 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. |
|
|
|
|
|
metachief
|
Posted: 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 |
|
|
|
|
|
BigBear
|
Posted: 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. |
|
|
|
|
|
CodeMonkey2000
|
Posted: 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. |
|
|
|
|
|
metachief
|
Posted: 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) |
|
|
|
|
|
richcash
|
Posted: 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. |
|
|
|
|
|
The_Bean
|
Posted: 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
Turing: |
View.Set ("graphics:500,500,offscreenonly,nobuttonbar")
var x, y : int
loop
for angle : 0 .. 360
cls
x := round (cosd (angle ) * 100) + maxx div 2
y := round (sind (angle ) * 100) + maxy div 2
Draw.Oval (maxx div 2, maxy div 2, 100, 100, 7)
Draw.FillOval(x,y, 5, 5, 7)
Draw.Box (x - 25, y - 25, x + 25, y + 25, 7)
View.Update
delay (25)
end for
exit when hasch
end loop
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
|
|