Yeah, physics.

**Horizontal movement:**In each cycle:

x = x + vx

If <left key pressed> Then

vx = vx - a

Else If <right key pressed> Then

vx = vx + a

Else

If vx > 0 Then

vx = vx - f

Else

vx = vx + f

End If

End If

If <collision with map> Then

<track back to furthest possible location>

End If

Where x is your horizontal coordinate, vx is your horizontal velocity, a is your horizontal acceleration, f is your horizontal friction.

**Vertical movement:**In each cycle:

y = y + vy

vy = vy + g

If <jump key pressed> Then

If <player standing on a platform Then

vy = vy - j

End If

End if

If <collision> Then

<track back to furthest possible location>

End If

Where y is your vertical coordinate, vy is your vertical velocity, g is gravity, j is jump strength.

It's not hard at all once you understand the equations. This needs decimal variables to work, keep that in mind. Better than using floats would be using some kind of fixed point math, something like using X bits for the decimal part and Y bits for the real part. For example, if you use 16 bits integers and have pixel coordinates in the range of 0-320 (for example), you could multiply/divide by 64 to gain six digits after the decimal point, thus gaining a precision of 1/64 of a pixel.

xOnScreen = x \ 64

x = xOnScreen * 64

This means that to actually advance one pixel you have to add 64, not 1. But that means that you can get smooth movement 'cause everytime you add 1 to x you are in fact "advancing 1/64 of a pixel".

A good understanding in kinematics helps a tad. Basicly you are using the accelerated movement equations:

v = v0 + a * t

s = s0 + v0*t + 1/2 * a * t^2

I was planning on writing a tutorial for this on QBE, I have to find time to do it.