After talking with Limited about some stuff, I realized that there are a few more things that I should note.
It is incredibly important that you watch what units you are using. You cannot add velocity and acceleration, for example; this would be like adding mass and speed, it just doesn't give you anything and doesn't really work. If you have to, write things out on paper before programming them. Do some sample math, try whatever works. What I explained was more of a math thing than a programming thing but you must keep these math concepts in mind when working on your implementation.
Another thing that may make your life easier: work under the assumption that your acceleration is constant along each axis. Working with gravity as the only vertical acceleration and the player's movement for the horizontal will not only simplify what you have to do but it will also allow you to use those formulas I mentioned. Those formulas are really useful, make sure to use them.
Here is a description of the three basic units that you will be working with, if my quick description above didn't help.
Displacement is a vector (it has magnitude and direction) that describes how much something has moved. To figure out the displacement from one point to another, simple subtract the new position from the old. Mathematically, xnet = x - x0. Normally this would be measured in meters or feet ( m ) but you could probably get away with using pixels for displacement instead of translating it from meters.
Velocity is another vector that describes the time required to move from one point to another. You could also say that it is the speed, but that is not technically correct since speed is not a vector. Anyway, velocity is measured in distance units over time. Again, you would normally use meters or feet per second ( m / s ), but since we are dealing with a computer you could probably get away with pixels per second.
Acceleration is yet another vector but in this case it describes how fast something gets fast. It is usually measured in meters or feet per second per second ( m / s / s ), but again you could probably get away with pixels per second per second.
Using these units along with t and mass, you should be able to find force and the other units, assuming you left your acceleration as a constant. You should have a better idea of what these units are.
Bookmarks