   Controlling speed of a 2D game.
  How would you control the speed of a 2D game so everything would move at the same speed regardless of the actual FPS? 
  There are a couple of methods, but I''ll just give you one of the most prominent here.You can base all of your calculations on a delta T.  This delta T could be calculated from the current time minus the the recorded time from the previous frame.   ______________________________________________________________The Phoenix shall arise from the ashes...   ThunderHawk -- ¦þMySite______________________________________________________________ ;  C++/win32 function that move a X position independent of FPS if called each frame.. However, you should not really use timeGetTime() inside the actual function...  void MoveDude(float& XPos){  static double lastTime = 0.0f;  double currTime = (double)timeGetTime() / 1000.0f;  double dTime = currTime - lastTime;  const double cSpeed = 10.0f;  XPos += cSpeed * dTime;  lastTime = currTime;} ----------------------------------------------Petter Nordlander"There are only 10 kinds of people in the world. The who understand binary and those who don''t" ;  I usually lock my game to 30 frames per second in the message handler like this-int cWinShell::Run(){  MSG  msg;  DWORD StartTime;  if (!GameInit())  return false;   while(TRUE){    StartTime = GetTickCount();    if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)){  if (msg.message == WM_QUIT)   break; TranslateMessage(&msg; DispatchMessage(&msg;    }    GameLoop();  while ((GetTickCount() - StartTime) < 33);  } // end whileGameExit();return msg.wParam;}I;  Locking the FPS helps a lot, by simply dividing the speed in pixels per second by 30 and moving that much per frame, you can achieve your goal, but what if the computer drops below 30 FPS (gasp!  I''d hate to program on that if the game was 2D)?To just put things nicely, find the frames persecond (FPS) and divide your speed in pixels by that, then move that much each frame.EX: Buba wants to move right 100 pixels, Buba has a speed of 10 pixels persecond.  You find the current FPS (I don''t really know how, lots of people can tell you though, but we''ll use 50 here), then divide 10 by the FPS (50) (10/50 = 0.5).  Now move Buba 0.5 pixels.  Each time the game comes around that second, it will move him 0.5 pixels, and within a second he will have achieved his speed of 10 pixels that second.  In addition, it will provide smooth movement because it is broken up into lots of movements.This process can be used on virtually anything to determine the speed necessary.Hope that''s what ya wanted!   I shot the sherif, and the deputy, and your wee doggie too! ;  FlipCode has a Tip of the Day dealing with this subject, that I found instructive.Hope this helps Joshvertexnormal AT email DOT comCheck out Golem at:My cheapass website