A lot of shmups have enemies that appear to be following a curve when they appear on-screen. I know how to move a sprite object using waypoints, but I'm less sure when it comes to bezier curves, since the control points aren't actually the curve itself. Here's my formula, which totally isn't my own work:

private Vector2 GetPoint(float t, Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3) { float cx = 3 * (p1.X - p0.X); float cy = 3 * (p1.Y - p0.Y); float bx = 3 * (p2.X - p1.X) - cx; float by = 3 * (p2.Y - p1.Y) - cy; float ax = p3.X - p0.X - cx - bx; float ay = p3.Y - p0.Y - cy - by; float Cube = t * t * t; float Square = t * t; float resX = (ax * Cube) + (bx * Square) + (cx * t) + p0.X; float resY = (ay * Cube) + (by * Square) + (cy * t) + p0.Y; return new Vector2(resX, resY); }

And here's the code I'm using to render the curve:

spriteBatch.Begin(); Vector2 PlotPoint; for (float t = 0; t <= 1.0f; t += 0.01f) { PlotPoint = GetPoint(t, controlPoint0, controlPoint1, controlPoint2, controlPoint3); spriteBatch.Draw(blank, PlotPoint, Color.Gray); } spriteBatch.End();

The curve renders fine, but I can't for the life of my figure out how to make my sprite object follow the curve. I've tried a couple of things and failed, but I feel like I'm missing some basic comprehension here. Any assistance will, as always, be greatly appreciated.