For a fixed-time game, (that is, a game where you want the framerate to be specific, like 15, 30, 60, etc.), you generally figure out the framerate you want, then base all the movement speeds of your players, enemies, etc. on their own speed. Thus the player might move 2 pixels a frame, enemies might move 1 pixel a frame.
Beyond that, what you need to do to fine-tune the movement speeds between things is to add either floating point variables or bit-shifted movement. Floating point is easier, bit-shifted is somewhat faster (though the difference is not as pronounced anymore as it once was.)
With floating point, everything has a decimal value, so you could assign a number to have a value of 3.7698, or 1.87658100647, or just plain 5.0. When you move an object, you can then move in smaller increments than a single pixel, such as:
myFloat += 0.25;
Bit-shifting is a little harder, but faster, and doesn't force you to do floating point arithmetic. Basically, with bit-shifting, you are deciding ahead of time how many increments should be between each pixel, and then your positions are decided accordingly, but you must use powers of two. For instance, if you want 64 increments between each pixel, that would be 2 to the power of 6, so you bit-shift by 6 whenever you draw something to the screen.
In this scenario, something at coordinates 640,384 is actually at pixel coordinates 10,6, because your drawing operation looks like:
And by having the larger numbers you can now move objects with more precision. You just have to remember that if you want to set something based on pixel coordinates, you have to bit-shift the other way. For instance, if you want to place something at pixel coordinates 40,87 you would do:
spriteX = 40 << 6;
spriteY = 87 << 6;
The reason you use bit-shift operators ( << and >> ) instead of multiplication ( * ) is because multiplication is much slower in terms of CPU time.
Note though that you cannot bit-shift floating point numbers, only integers.
--- Kris Asick (Gemini)