Click to See Complete Forum and Search --> : A moving character....


Homestead
January 15th, 2004, 09:45 PM
I would like to move my char for example 'A' in a wave form as A= sin(x), but I dont know how to make its motion visible ?
My char flies somewhere I dont know.

What I should do to implement that function correctly ?

Regards,

Fiona

Myself dot NET
January 17th, 2004, 09:48 AM
Well you would first need to write some code to calculate the appropriate y value for an x value of the character. If your windows client area uses the default MM_TEXT mapping mode, you could use something like

y = (cy / 2) * (1 - sin(2 * PI * x / cx));

where cx and cy are the width and height of the client area, respectively. This is assuming you want the sine path to take up the whole client area. Then you would need to set a timer which increments x and invalidates/erases the client area. Your paint handling would then output the character at (x,y).

Homestead
January 17th, 2004, 01:42 PM
Originally posted by Myself dot NET
Well you would first need to write some code to calculate the appropriate y value for an x value of the character. If your windows client area uses the default MM_TEXT mapping mode, you could use something like

y = (cy / 2) * (1 - sin(2 * PI * x / cx));

where cx and cy are the width and height of the client area, respectively. This is assuming you want the sine path to take up the whole client area. Then you would need to set a timer which increments x and invalidates/erases the client area. Your paint handling would then output the character at (x,y).
I didnt see my thread was replied...that s why I am late for my many-a-Thank to You...:)

Regards,

Fiona