This forum is read only and just serves as an archive. If you have any questions, please post them on

9 years ago by develix


I just wondered how it's possible to slowly move an image on an parabola arc with canvas on impact.
All my attempts failed, I would be excited if someone can provide an example working with impact.


9 years ago by Apiheld

Show some code please, what did you try so far?

Also, you shouldn't just move an image across the screen. The screen only represents the game world with its entities, which is entirely in memory. Better move an entity in a parabolic arc and then render that entity.

9 years ago by drhayes

Here's a bezier function I'm using in my game.

It's a quadratic bezier so you have a start point, an end point, and two control points along the way.

The function works for x and y coordinates like so:

entity.pos.x = bezierPoint(this.p[0].x, this.p[1].x, this.p[2].x, this.p[3].x, this.t);
entity.pos.y = bezierPoint(this.p[0].y, this.p[1].y, this.p[2].y, this.p[3].y, this.t);

t should go from 0 (start point) to 1 (end point) over some period of time, however long you want the move to go.

Apiheld is right; you probably want this to be an entity so it receives updates and exists in the draw order in a sane way.

Here's a good starting point for the parabola-to-bezier part.
Page 1 of 1
« first « previous next › last »