I''m working on a simple scripting engine for running moving platforms in my side scroller (a year ago I would have derived a class for every platform in the game

). Working great; I can get it to initialize, move, delay and even set the parser on the fly or wait for the player to jump on it.
Now, what I''d like to be able to do is move the platform in an arc. Say I want to move from (600, 850) to (600, 650). 200 pixels straight up. Now, how can I control the curve the platform travels? Maybe I want a very subtle curve. Maybe I''m moving from under a platform to over it and I want a half-circle. Maybe I want the destination and the source to be equal, and for it to move 360. This all works off keyframes, btw, so I want to be able to interpolate by time deltas.
I guess I''m looking for math to figure out a path between two points given, say, an angle, or whatever it takes. Like I''d get my half-circle by passing 180 (or a half circle in the other direction with -180) or a more subtle curve with, say 30. Or my circle with 360. Actually, I''d probably be using rads, wouldn''t I?
Say I''m going from (600, 850) to (600, 650) and my angle is 180. That makes my midpoint (600, 750). Or if my angle is 90, the midpoint would be (500, 750) (and -90 would be (700, 750)). How do I calculate a midpoint like that? Just so you know, this is how my script language works:
start(192, 160);
moveto(320, 160, keyframe(256));
stall(keyframe(200));
moveto(320, 480, keyframe(640));
moveto(192, 480, keyframe(128));
moveto(192, 160, keyframe(320));
setparser(16);
Platform moves in a rectangular loop, stopping for a second in the upper-right corner (just for testing). Boy; that''s a long post

Basically, I want to be able to have an arc(600, 650, 180); if possible. To be able to determine a midpoint of an arc from 2 endpoints and an angle. And I believe (hope) I can them interpolate from one point to another using the angles from the midopoint to the two endpoints.
Can anyone show me the math for something like this? Thanks muchly

Chris Barry (crbarry at mts.net)
My Personal Programming Depot