I am Currently working on One 2D Android Game,

In this game One ViewObject(Bitmap) is moving Across Screen On Parabola Path Like in this Image, But this Path is Static, the Static path is getting throught the Drawing with Fingure on canvas,

As Same as signature Drawing. enter image description here

The Bitmap Move code On this Static Path is

//animation step
private static int iMaxAnimationStep = 900;
private int iCurStep = 0;
private Path ptCurve = new Path(); //curve
private PathMeasure pm;            //curve measure
private float fSegmentLen;         //curve segment length

 //init smooth curve
    PointF point = aPoints.get(0);
    ptCurve.moveTo(point.x, point.y);

    for(int i = 0; i < aPoints.size() - 1; i++){
        point = aPoints.get(i);
        PointF next = aPoints.get(i+1);
  ptCurve.quadTo(point.x, point.y, (next.x + point.x) / 2, (point.y + next.y) / 2);

    pm = new PathMeasure(ptCurve, false);
    fSegmentLen = pm.getLength() / iMaxAnimationStep;//20 animation steps

    //animate the Bitmap
    Matrix  mxTransform = new Matrix();
    if (iCurStep <= iMaxAnimationStep) 

        pm.getMatrix(fSegmentLen * iCurStep, mxTransform,
        mxTransform.preTranslate(-Bitmap.getWidth(), -Bitmap.getHeight());

       canvas.drawBitmap(Bitmap, mxTransform, null);

        iCurStep++; //advance to the next step
    } else {
        iCurStep = 0;


But My Problem is I want to Move This ViewObject(Bitmap) On Dynamic Path(in parabola curve) & that Dynamic curved path will work in Any Device.

I have searched Lot but i can't Find Solution How to get Dynamic Path (in parabola curve).

help! If you have Any Solution,Suggestion, idea ,tutorial regarding this post is Mostly Appreciated.

  • \$\begingroup\$ You may want to clarify your question, as it seems unclear at the moment. \$\endgroup\$ Commented Jun 11, 2013 at 22:23

3 Answers 3


If I understand your question correctly, you're looking for a damped harmonic function which would be something along the lines of f(x)=e^x*sin(x). In this function x would be time and it would give you the vertical acceleration of the bounce.

An example of an optimized version of the function to your situation might be An example of an optimized version of the function to your situation might be ![ (replaced x with t for time) which would result in the graph of: enter image description here

At f(0), the function will return 1 or the full "force" of the bounce. You cannot have a -delta_time the function has a limited domain of t >= 0 so the function always returns a number between -1 and 1 so you can use it as a scalar for a velocity.

If you just want the height of a bounce just get the absolute value so it becomes enter image description here which will look like:

enter image description here

This is a scalar from 0-1 so just multiply it by the height: enter image description here

Images courtesy of Wolfram Alpha

  • \$\begingroup\$ thanks for ur answer that better understand physics behind this question. \$\endgroup\$ Commented Jun 12, 2013 at 6:11
  • \$\begingroup\$ That looks cool, but it isn't physically correct. The waves you got there are no parabolas, is are damped sine functions. To be correct, it should have parabolas, in order to get a realistic gravitation effect. \$\endgroup\$ Commented Jun 15, 2013 at 13:31
  • \$\begingroup\$ @MartijnCourteaux - They are making a simple animation not a physics simulation clearly. \$\endgroup\$
    – stas
    Commented Jun 17, 2013 at 0:27

I would recommend looking at Box2D. It is a physical engine that will take care of all the physics your game needs. However, if you think this engine is an overkill, just write the simple bouncing mechanism yourself.

Create a vector acceleration, a vector velocity and a vector position. Then on each frame you use the formula's found by integration. Assume step is your timestep in seconds (which is probably something like 1/60).

position += integral(velocity, 0, step), where
velocity += integral(acceleration, 0, step), where
acceleration = (0, -9.81).

So substitute these things in each other gives:

velocity += integral(acceleration, 0, step);
vector velocity0 = velocity;
velocity = velocity0 + vector(acceleration.x * step, acceleration.y * step);

The same for position:

position += integral(velocity, step)
position += integral(velocity0 + vector(acceleration.x * step, acceleration.y * step), 0, step)
position += vector(velocity0.x * step + 0.5 * acceleration.x * step * step, velocity0.y * step + 0.5 * acceleration.x * step * step);

So the code you have to apply each frame is:

vector velocity0 = velocity;
velocity += vector(acceleration.x * step, acceleration.y * step);
position += vector(velocity0.x * step + 0.5 * acceleration.x * step * step, velocity0.y * step + 0.5 * acceleration.y * step * step);

Now, to bounce, just check when position.y < 0. If that happens, do this:

velocity = vector(velocity.x, -velocity.y * restitution)
position.y = 0

Where restitution is a factor between 0 and 1. A normal value would be like 0.6.

  • \$\begingroup\$ thanks for your answer but i don't have to use other game engine \$\endgroup\$ Commented Jun 12, 2013 at 6:09
  • \$\begingroup\$ Just keep reading. Only the first sentence of my answer was referring to a physics engine. The whole other part is about doing it yourself. \$\endgroup\$ Commented Jun 15, 2013 at 13:32

Go with simple kinematics. after every bounce the velocity that the entity collided with becomes the initial velocity for the next move. The entity moves in a parabola because of acceleration due to gravity, repeat until many times as necessary. For different curve shapes(more narrow or wider) experiment with direction and velocity at which the object moves.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .