Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to define the movement of an object for a danmaku game I am making. Here is a link to some example gameplay (not my game, but a popular series in this genre made by Zun). Basically, I was thinking that any object's movement (in a 2-dimensional plane) can be defined using just two functions. This is a 2d game and so there are two axes. It will have a velocity in pixels/secs for the x-axis and for the y-axis with positive numbers being velocity going right for the x-axis and going up for the y-axis. I was thinking that no matter how complex the pattern of the object, I can define it using two functions. Maybe it isn't practical to define their movement this way, but I was wondering if it is theoretically possible.

I hope that my question was explained clearly enough. Also, if you know of any books that deal with this sort of thing that would be nice to know about as well. I also did not now what tags to put on this so some of these may be wrong.

share|cite|improve this question
That seems like the standard way of doing it. Anyways, it would certainly seem like it's the way done in Touhou. See this link. – EuYu Nov 3 '12 at 4:34
Thank you EuYu. That link was very helpful. It seems that they use velocity and direction instead of a velocity for the x and y axes but it seems accomplish the same thing. Maybe doing it with direction and velocity is easier though? – russjohnson09 Nov 3 '12 at 5:01
They use a Hermite spline curve for some reason. I have no idea of the actual reason, but perhaps direction/velocity is more compatible for the bullet patterns generated. – EuYu Nov 3 '12 at 5:06
up vote 1 down vote accepted

Indeed, this is a sensible approach, and you've started to stumble upon the wide world of numerical methods for solving differential equations. "Differential equations?" you say. "I didn't say anything about differential equations!"

But you really did. Knowing the velocity of an object at any given time (i.e. both the x- and y-components of velocity), you'll wonder how best to go from that velocity to a new position.

In other words, if $x(t_0) = x_0$, what is $x(t_0 + \Delta t)$, where $\Delta t$ is the time between frames? If you know the velocity $v_x(t_0)$, then a simple approach is to say $x(t_0 + \Delta t) = x_0 + v_x(t_0) \Delta t$. This is the Euler method, and it's simple, but not terribly accurate. Better methods include the whole class of Runge-Kutta methods for numerical integration, but they may be more advanced than the situation requires.

Nevertheless, I think it's crucial to realize that, knowing the velocity and position at a given frame, there are many ways to estimate the new position on the next frame, each with varying levels of precision and complexity, and you as the developer have the freedom to choose what best fits your application. It's actually quite an exciting topic.

share|cite|improve this answer
I was thinking that there will be enough frames per second that I would use the Euler method, although I didn't actually know that was its name until after what you said. – russjohnson09 Nov 3 '12 at 11:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.