6 ms·
Basically it's two things: 1. answering the question "how do we get the next x" for a function x=y. If x=y, then if you increase x, you also increase y, so dx
by tenebrisalietum 4y ago
Basically it's two things:
1. answering the question "how do we get the next x" for a function x=y.
If x=y, then if you increase x, you also increase y, so dx/dy=1. Figuring out dx/dy is fun when dealing with things like 3x^2+5x+7=y.
But take the game of Pong, for example. A simple Pong game has a ball and the direction of the ball can be controlled by two variables - horizonal velocity (H) and vertical velocity (V).
Each frame, you take the ball's X and Y and add H and V to it, to move the ball. When the ball collides with something, just multiply by -1 (to flip the sign) to reverse the ball.
If you divide V by something like 0.0001 each frame, you will implement gravity.
Want the ball to have a gravity or other "pull" that results in it hitting a point in a specific number of frames? Well ... someone who knew what they were doing would know what to do. That's all I got.
2. If you have a few points for x=y, you should be able to figure out dx/dy somehow. I think that's called integrals.
- treis 4y ago>If you divide V by something like 0.0001 each frame, you will implement gravity. That'd be a wild ride.
- itishappy 4y agoMinor correction: > If you divide V by something like 0.0001 each frame, you will implement gravity. You will implement air resistance. Air resistance is proportional to the velocity, gravity is a constant offset. V(n+1) = V(n) - drag * V(n) - gravity
- behringer 4y agoOh sure, that's simple enough. How about gravity over a sphere in 3 dimensions? How about a custom physics and collision engine? How about some portals? How about some non linear spaces? Games get incredibly complicated very quickly.