Help with sin/cosine movement
-
Hi
I'm terrible at math and i'm looking for help to incorporate som sin or cosine movement into the placement of a drawtext. (Like an old fashioned scrolltext back in the demo days).
So the text placed on screen would move (wave) up and down or side to side in a smooth way (Think of ease in/ease out).
Hope this make sense to you all.Best Regards
// Andreas M
-
sin/cos in FUZE4 uses an angle as a parameter, so you'll get a floating value between -1 and 1 if you supply values between 0-360. The cycle starts again at 360, so sin(2) will for example give the same value as sin(362).
So, you basically have to scale both the angle parameter and the return value to your liking, to behave as your screen coordinate system.
(sin(xcoord)+1)*180
...would give you y-coordinates between 0-360, meaning a "perfect" sine wave. -
try this
loop clear() x = sin(time()*1000)*500-250 y = cos(time()*1000)*500-250 drawtext(x,y,30,random(120),"Hello FUZE!") update() repeat
-
@MikeDX
How Will i declear βtimerβ ??
Function Does not exist.// Andreas
-
sorry Andreas
i meant time() not timer() π
-
I ger error on the random for the colour, wants a vector...
And when setting a colour manualy the the Sine/Cosima is waaaaay to fast. -
Great! so we have a start :)
try changing random(120) for another colour, let's say red, white, etc
for the speed, the time()*1000 is the key here. lets try 100
-
@MikeDX
Works alot better, smooth and nice :)
Thanks Alot// Andreas
-
Great! Now you can experiment with speed, colour range etc and you'll be a sincos master in no time