1. ## trajectory: getting a ball to follow a line.

right. my peril continues. in my effort to make a program which illustrates different trajectories of a cannon positioned at different angles and units of power, i've gotten to a big hook-up:

(by the way, i'm using the windows gdi)

yesterday, to my glee, i managed to program a bezier curve to illustrate the aforementioned paths. however, i then realized that although i can make a line show this arc, i haven't the slightest idea where to begin when it comes to making a picture follow this line.

so anyway, some help would be appreciated.

2. Depends how you're doing the line. If you're using Bresenham for example, then you can easily store delta x and delta y values for the ball and increment these every frame.

But considering that you're talking about Bezier curves, it will be more complex. Delta x and delta y are likely to vary across all points, so it'll be a case of sitting down with the equation and playing with it until it gives you an array of points or can operate stepwise (give you x and y at a time).

3. bressenham? what's that? could you tell me, maybe, what you're talking about, or how to use it? i'd check msdn, but i'm responding to this on my psp.

4. Never mind. Professor Jack Bresenham came up with a simple algorithm to draw straight lines when he worked for IBM in the 60s. Now that I've realised that you're using GDI functions instead of your own stuff... you've got a long way to go.

5. yeah, i kinda said that i was using gdi. but uh, thanks for telling me that my method wasn't as good as some ancient algorithm, then realizing what i was talking about and offering your condolences by telling me i have a long way to go.

i was thinking though, that maybe using a bezier curve isn't the right way to go, mainly because working with power and angle, i can't always get the angle to act accordingly with the power. for example, the same power with a 10 degree angle goes farther than a 45 degree one. that's a problem.

I was thinking of implementing some sort of speed variable, which would depend on the power. the speed would slow down over a relative period of time, due to the simulation of air friction.

the picture i have would follow the slope of the angle, and as the speed decreased, the slope would get nearer to, then less than, zero, and proceed downward in the same way it started. this method would probably also be capable of adding in wind, affecting the trajectory.

the thing is, i'm sure a billion cannonball trajectory programs have probably been made, so there's probably some genious who's come up with the best way of doing it. i was just looking for those kind of tips.