0
$\begingroup$

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.

  • 0
    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.2012-11-03

1 Answers 1

1

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.

  • 0
    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.2012-11-03