3 Answers
3

A vertical acceleration due to the magics of gravity. This will be ay.

A horizontal component: Without air friction this is a constant velocity.

Let's say you throw the ball and at the moment of leaving your hand it has a velocity v0 = (v0x, v0y) and is at position p0. Then v0x will be constant for all time.

The speed of the ball at time t would be v(t) = (v0x, v0y + t * ay)

For each tick of your animation, add deltat * v(t) to the current position of the ball and you should be set.

Everytime the ball bounces, you should mirror its velocity vector on the surface it bounced and substract a certain percentage of its total energy (Ekin + Epot, although Epot will be 0 if it is on the ground and the gound is zero potential), in order to get a logarithmic bouncing.

If you want air friction too, just substract a certain small percentage of the total energy with every animation tick.

Here some code, not in ActionScript, but I hope readable. (The parameters to the ctor are both Vector2d; clone() used implicitly but you can guess what it does):

Depends on where his axes point. If it is on a monitor where y=0 is the top and y=100 is the bottom, the addition of a positive acceleration would be advised. Better let the acceleration vector point to the indicated direction and a sum will always work.
–
HyperboreusMay 27 '11 at 17:52

I think you meant to say "2. A horizontal component: without air friction, this is a constant" The horizontal component of the acceleration is zero, and the horizontal component of the velocity is constant.
–
phoogMay 27 '11 at 17:53

@phoog I edited it to "constant velocity".
–
HyperboreusMay 27 '11 at 17:54

A couple things: (a disclaimer: I am not familiar with actionscript at all but I have made a couple games needing throwing arcs.)

First, cos and sin both have bounds between -1 and 1. Generally x is plotted in pixels, so changing x by 0.5 isn't going to make a difference visibly. Also, since x should be an int, it wouldn't even show.

Secondly, the computation power needed to compute this type of physics probably isn't necessary--maybe it is if you're doing an exact physics simulation.

Also consider Hyperboreus' second comment: horizontal is generally constant. Thus, assuming that this is side-scroller-esque, you would need to vary the y component and not the x.